calculating cube roots

Can anyone help me with Java code that will calculate the cube root of double values?If you know the necessary code, or can helpme find existing code, it would be much appreciated.Thanks, W3333
[235 byte] By [W3333a] at [2007-9-29 13:18:06]
# 1
Can you not use Math.pow(value, 1/3)? (I know that there is a bug report to do with cube roots, but don't have time to find it right now :) )
detlya at 2007-7-15 3:31:11 > top of Java-index,Other Topics,Algorithms...
# 2

> Can you not use Math.pow(value, 1/3)? (I know that

> there is a bug report to do with cube roots, but don't

> have time to find it right now :) )

That should be Math.pow(value, 1.0 / 3) ;-)

I am curious about the "bug". The closest thing I could find is this:

http://developer.java.sun.com/developer/bugParade/bugs/4347132.html

which is more of a feature request for taking the cube-root of a negative number.

rkippena at 2007-7-15 3:31:11 > top of Java-index,Other Topics,Algorithms...
# 3

> I am curious about the "bug". The closest thing I

> could find is this:

>

> http://developer.java.sun.com/developer/bugParade/bugs/

> 347132.html

>

> which is more of a feature request for taking the

> cube-root of a negative number.

Ah yes, that was it :) Feature request, bug report, whatever :P

I can never remember how Java deals with float/int conversion. Every time I use floats point whole numbers, I siffix them with a '.' (like Math.pow(value, 1./3.)).

detlya at 2007-7-15 3:31:11 > top of Java-index,Other Topics,Algorithms...
# 4
Do you mean you want to know how to write the algorithm that underlies Math.pow for yourself? If so, Newton-Raphson iteration is what you want: http://www.library.cornell.edu/nr/bookcpdf/c9-4.pdfMOD
duffymoa at 2007-7-15 3:31:11 > top of Java-index,Other Topics,Algorithms...
# 5
Thank you for providing me with the info I was looking for.I did not realize that Math.pow could do cube roots.My program is now working correctly.Sincerely,W3333
W3333a at 2007-7-15 3:31:11 > top of Java-index,Other Topics,Algorithms...
# 6
Thanks for that info. I just needed Math.powafter all. I am interested in seeing how it isdone, however.Thanks,W3333
W3333a at 2007-7-15 3:31:11 > top of Java-index,Other Topics,Algorithms...