 |
BOOK: Beginning Java 2  | This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 28th, 2004, 10:43 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to determine cube root of a number...
Hi All,
Just wanted to understand how to determine the cube root of a double value. I know that to determine square root we user Math.sqrt(num).
In fact how do we determine fourth root, fifth root (nth root)??
I'd be grateful if you could let me know.
Have a great day,
BTW, Happy new year to y'all.
Kaizer.
Kaizer Billimoria
Bangalore, India
__________________
Kaizer Billimoria
Bangalore, India
|
|

January 29th, 2004, 05:33 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

January 29th, 2004, 06:56 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I don't know anything about Java, but if it's got the ability to calculate the log of a number then you can easily do nth roots like this:
take the log of the number you want to find the nth root of
divide the log by n
take the exponent (inverse log) of the result and that's the nth root
so in pseudo-code:
nthroot = exponent( log(number) / n )
hth
Phil
|
|

January 29th, 2004, 08:18 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Martyn, pgtips,
Martyn, your url takes me to a blank reply screen... humbly suggest you retry. Thanks in advance..
pgtips, i assume that when you say log you mean log (base 10) and not log (base 2). i believe you mean common logarithms? If that is the case yup java does have that log-ability...thanks for your inputs i'll try it out anyhow.
Have a great day.
kaizer.
Kaizer Billimoria
Bangalore, India
|
|

January 29th, 2004, 08:30 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I was actually thinking of the natural logarithm (base e), but it doesn't matter which base of log you use as long as you use the corresponding inverse log.
|
|

January 29th, 2004, 08:41 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
pgtips,
Thanks for the clarification. before i run along and try it out just one more clarification... what does n represent in your solution? is it the number itself or is it something else?
kaizer
Kaizer Billimoria
Bangalore, India
|
|

January 29th, 2004, 08:57 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Martyn
Appreciate it.
Kaizer
Kaizer Billimoria
Bangalore, India
|
|

January 29th, 2004, 09:20 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Quote:
quote:Originally posted by kaizer
pgtips,
Thanks for the clarification. before i run along and try it out just one more clarification... what does n represent in your solution? is it the number itself or is it something else?
kaizer
|
You wanted the nth root, so that's what n represents. If you want the cube root, set n=3. The number itself is represented by the word 'number'. 
|
|

January 30th, 2004, 12:22 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks pgtips, sometimes the obvious is not so obvious.:D
have a great day,
kaizer
Kaizer Billimoria
Bangalore, India
|
|
 |