root _2

Hi, can some help, i want to program for root 2, using Newton-Raphson method.
x_(n+1)=1/2 x_n+1/x_n

Last edited on
Consider x^2 = 2, (i.e. x = sqrt(2)), then rewrite this as

f(x) = x^2 - 2 = 0.

Newtons method is

x_{n+1} = x_n - f(x)/f'(x) = x_n - (x^2 - 2)/(2x)

So choose a suitable initial condition for x_0.

You know the answer will be greater than 1 and less than 2 so pick something like 1.5 for example. Then calculate x_1, x_2, etc... until the difference between two successive x values is less than some small value like 0.0000001 for example. Or alternatively, keep calculating x values until f(x)/f'(x) is small enough.
newtons method is the easiest to do.
estimation = ( estimation + ( square_root / estimation ) ) / 2;that is the general idea of the formula. according to theory estimation can start as anything but 0.
can u show me, how to express the formula, to estimate the value of sqrt(2).
take my formula. start estimation as 1. and square_root as 2 and estimation will be ur answer after u run the equation in a for loop 10 times.
Topic archived. No new replies allowed.