English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I try to program an algorithm can find the cube root of a number. Because a number's integer exponent and square root and the arithmetic operation are built in in the language I'm using. So I want to know if there is anyway to find the cube root with the built in functions.

2007-01-26 09:39:38 · 2 answers · asked by Mgccl 1 in Computers & Internet Programming & Design

2 answers

Here is an algorithm which uses the Newton-Raphson Method.

f(x) = x^3 = b
f(x) = x^3 - b = 0
f'(x) = 3x^2

x.(n+1) = x.n - f(x)/f'(x) = x.n - [x^3 - b]/3x^2

Several iterations of this equation will return an approximation of the cube root of "b" which will exceed the accuracy of any calculator.

The closer your initial value of x.0 is to the actualy cube root of "b", the faster it will get there.

eg.

x^3 = 9
b= 9

x.0 = 2
x.1 = 2 - [ 2^3 - 9]/[ 3 * (2)^2] = 2.0833333
x.2 = x.1 - [(x.1)^3 - 9]/[3 * (x.1)^2] = 2.0800888888
x.3 = x.2 - [(x.3)^3 - 9]/[3 * (x.2)^2] = 2.08008382306

After three iterations, you get a good approximation of the cube root of 9.

2007-01-26 12:23:16 · answer #1 · answered by Kookiemon 6 · 0 0

Square root the square root ...

2007-01-26 17:49:57 · answer #2 · answered by wupmeuk 2 · 0 0

fedest.com, questions and answers