432,650 Members | 1,785 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

# Tips For Find Cube Root Program Using C++

 P: 1 Hi, i found the new method of find cube root of the given value.i want to implement in the c++ program.ex: if you give the answer the certain value i find the cube value.(i.e)if you give the ans 1331.i find the cube root is 11.i want to implement in the program please give some tips... Jan 2 '08 #1
4 Replies

 Expert 100+ P: 1,764 Hi, i found the new method of find cube root of the given value.i want to implement in the c++ program.ex: if you give the answer the certain value i find the cube value.(i.e)if you give the ans 1331.i find the cube root is 11.i want to implement in the program please give some tips... Cube root is nothing but a double sqrt. You sqrt once,and then sqrt result again. If you want to find perfect cube root check whether int result on cube is same as start value,and if it is.......... Savage Jan 2 '08 #2

 Expert 100+ P: 671 So what you're saying is... ((x)^.5)^.5 = x^(1/3)? Are you absolutely certain ;) Jan 2 '08 #3

 Expert 100+ P: 1,764 So what you're saying is... ((x)^.5)^.5 = x^(1/3)? Are you absolutely certain ;) Oops,i got it wrong,i was thinking on quad root algorithm. :( Let's see,if it is cube root then he could use pow with 1/3 as second argument.. result=pow(number,(double)1/3); Savage Jan 2 '08 #4

 P: n/a google wikipedia, there's Halley's algorithm which seems to have the nice property that it's integer implementation won't oscillate between r and r+1 (as does Newton's method for some values) where r³ <= n <= (r+1)³ : int icbrt(int n){ int t=0, x=(n+2)/3; /* works for n=0 and n>=1 */ for(; t!=x;){ int x3=x*x*x; t=x; x*=(2*n + x3); x/=(2*x3 + n); } return(x); /* always(?) equal to floor(n^(1/3)) */ } Oct 23 '10 #5 