Newton's Method for estimating square roots.

6.8k Views Asked by At

Sometime ago I wrote a program that used Newtons Method and derivatives to approximate unknown square roots (say $\sqrt 5$) from known square roots like $\sqrt 4$.I have since lost the calculator and the book I got the equation from.

Edit Researched a bit let me see if I have this right.

First I start with my known $$\sqrt 4=2$$ then I subtract. Thus. $2-\frac {4-5}{(2(\sqrt (4)}$

Then I take that answer call it $r_{t1}$ and plug it back in so that I have $r_{t1} -\frac {{r_{t1}}^2-5}{2(r_{t1})}$ Rinse lather repeat..

Right?

2

There are 2 best solutions below

2
On BEST ANSWER

To find a square root of $a$ using Newton's Method, we can write:

$$f(x) = x^2 - a$$

This is because the roots would be:

$$f(x) = x^2 - a = 0 \implies x^2 = a \implies x = \pm ~ \sqrt{a}$$

Apply Newton's iteration:

$$x_{n+1} = x_n - \dfrac{f(x)}{f'(x)} = x_n - \dfrac{x^2-a}{2x}$$

Select an $x_0$ and iterate away.

You can find a worked example here.

0
On

I do not write out the program in its entirety, but instead give a step-by-step approximation of what the program should do. Using a basic TI-83 Calculator, we can write your program as follows:

1) Have the user input the underlying function for the desired root: Store this as a string to one of the function variables.

2) Have the user input the derivative of the function from (1) in the same manner: I have assumed that your calculator cannot take derivatives.

3) Have the user input a guess value, and store this value to a variable: I use $guess \to x$.

4) Use the Newton approximation equation to iteratively store successive approximations to a single variable: something like $x - \frac{f(x)}{f^\prime(x)} \to x$.

5) Create a loop to repeat the process: you can choose from various different ways to terminate the loop, be it decimal accuracy, number of iterations, or something else. Some of these are more complicated to encode than others.