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...
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..........
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)) */
}