### Welcome to our community

#### Sudharaka

##### Well-known member
MHB Math Helper

I was wondering how to find square root for numbers like 128. Can you do it step by step please?

#### SuperSonic4

##### Well-known member
MHB Math Helper

I was wondering how to find square root for numbers like 128. Can you do it step by step please?
I would use Prime Factorisation to find the prime roots and then take advantage of the rule $\sqrt{ab} = \sqrt{a}\sqrt{b}$. The numbers are positive so this is allowed. To that end if decimal approximations are needed, it's best to learn some of the simple prime roots like $\sqrt{2},\ \sqrt{3}\ \sqrt{5}$

Using 128 as an example (this one is relatively simple as an integer power of 2)

$128 \div 2 = 64$ -- so 2 is one prime factor
$64 \div 2 = 32$

and so on until
$4 \div 2 = 2$

Thus we can say that $128 = 2^7$ and so $\sqrt{128} = \sqrt{2^7}$

Using the rule above I then say that $\sqrt{2^7} = \sqrt{2^6}\sqrt{2} = 2^3\sqrt{2} = 8\sqrt{2}$

I would leave it as $8\sqrt{2}$ for an exact answer

#### MarkFL

Staff member
If you now wish to compute rational approximations for $\sqrt{2}$ by hand, here are two recursive algorithms (the second converges more rapidly):

i) $\displaystyle x_{n+1}=\frac{x_n+2}{x_n+1}$

ii) $\displaystyle x_{n+1}=\frac{x_n}{2}+\frac{1}{x_n}$

You simply need to "seed" both recursions with some initial guess.

We know $\displaystyle 1<\sqrt{2}<2$ so $\displaystyle \frac{3}{2}$ will work just fine.

#### soroban

##### Well-known member

Here's another recursive approximation for a square root.

Suppose we want $$\sqrt{N}.$$

Let $$a_1$$ be the first approximation to $$\sqrt{N}.$$

Then: $$a_2 \:=\:\frac{N+a_1^2}{2a_1}$$ is an even better approximation.

Repeat the process with $$a_2$$ . . . and so on.

This procedure converges very quickly
. . depending on $$a_1.$$

Find $$\sqrt{3}$$, using $$a_1 = 1.7$$

$$a_2 \:=\:\frac{3 + 1.7^2}{2(1.7)} \:=\:1.732352941 \:\approx\:1.732353$$

$$a_3 \:=\:\frac{3 + 1.732353^3}{2(1.732353)} \:=\:1.732050834$$

ChecK: .$$1.732050834^2 \:=\:3.000000091\;\;\checkmark$$

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Here is the reasoning behind this procedure.

We want $$\sqrt{N}.$$

We approximate the square root, $$a_1.$$

Suppose our approximation is correct.
Then $$a_1$$ and $$\tfrac{N}{a_1}$$ would be equal, right?

Chances are, they are not equal.
One is larger than the square root, one is smaller.

What is a better approximation of the square root?
. . . the average of the two numbers!

Hence: .$$a_2 \:=\:\frac{a_1 + \frac{N}{a_1}}{2} \:=\:\frac{\frac{a_1^2 + N}{a_1}}{2}$$

Therefore: $$a_2 \:=\:\frac{N +a_1^2}{2a_1}$$

#### Bacterius

##### Well-known member
MHB Math Helper
Soroban's method is called the Newton-Raphson method, by the way (if someone wants to search for more information on it). It tends to work most of the time, and converges remarkably quickly (twice as many correct digits per iteration, in general) but can also fail sometimes. This is related to chaos theory and notably used in fractal rendering, but can be mitigated by appropriately choosing the initial guess. It should be noted it cannot fail for polynomials of order less than 3.

Its general form is:

$$a_{n + 1} = a_n - \frac{f(a_n)}{f'(a_n)}$$

To converge to a root of $f(x)$. Which root it converges to is dependent on the initial guess $a_1$.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Mark's method ii, soroban's averaging method, and Newton-Raphson are all identical.

Generally, Newton-Raphson finds a root of $f(x)=0$.
The algorithm is:
$x_{k+1} = x_k - \dfrac{f(x_k)}{f'(x_k)}$​

With $f(x)=x^2-N$ this becomes:
$x_{k+1} = x_k - \dfrac{x_k^2-N}{2x_k}$

$x_{k+1} = \dfrac{x_k}{2} + \dfrac{N}{2x_k} \quad$ or $\quad x_{k+1} = \dfrac{N + x_k^2}{2x_k}$​

The initial guess should be above the root for fastest results.
If the initial guess is below the root, the first iteration will jump to the other side of the root and it will worsen the approximation.

The second form is the one soroban presented.

If we pick N=2 as Mark did, the first form becomes:
$x_{k+1} = \dfrac{x_k}{2} + \dfrac{1}{x_k}$​