35
$\begingroup$

Okay, I know this is very basic question. I learned 2 methods in school. But now, I forget one.

Here is a simple method that I know.

  1. Find the prime divisors of the number
  2. Omit the half of numbers that have been appeared even times
  3. multiply the rest

For example you want to find square root of 36. You find the divisors. They are 2x2x3x3. In step 2 they appeared as 2x3. That is 6. Problem is this method works when the square root is an integer number. It doesn't work for numbers that doesn't have integer square root. Like 38.

So my question is how can I find the square root of any arbitrary number using pen and paper?

$\endgroup$
4

7 Answers 7

36
$\begingroup$

You can use the identity $(x+c)^2 = x^2 + 2xc + c^2$ to arrive at a "long-division" like method. Let me show you how it is done for 3838 before giving the algorithm.

  1. Start with 3838
  2. Write the digits in groups of 2, so write 3838 as 38,38.
  3. For the "highest placed group of 2", find the biggest square number less than it. In this case, $6^2 = 36 < 38 < 49 = 7^2$. So you write down 6, and subtract 36 from the first group. You then get
  4. 2,38 = 38,38 - 36,00.
  5. Take the 6 you wrote down before, multiply it by 20 (so you get 120). Now find the largest multiple of $6\times 20$ that is less than 238. You'll see that it is 1. So you write down 1 (so your number is now 61). Subtract from 238 120 to get 118.
  6. Subtract from 118 the number $1 = 1^2$ to get 117. Now add two more digits to it (to form 117.00). Take 61, multiply it by 20, you get 1220. Find the largest multiple of 1220 less than 11700, which would be $1220 \times 9 = 10980$. So write down 9, and your number is 61.9, and subtract from 11700 the number 10980 to get 720. Subtract from 720 the number $9^2 = 81$ to get 639.

So you've arrived at, at this point, $3838 = (61.9)^2 + 6.39$. And you can continue the process indefinitely.

How does this work? Given a number $A$, you want to find its square root in base-10 representation. Suppose your square root looks like $$ a_{100}a_{10}a_1.a_{0.1}a_{0.0.1}\ldots $$ when expanded as a string of digits. Then you find the biggest $a_{100}$ such that $$ (a_{100}\times 100)^2 \leq A $$ (similar to how you do long division). Then to make solve for the next digit, you use that $$ (a_{100} \times 100 + a_{10}\times 10)^2 \leq A $$ (since you are truncating the decimal expansion, which makes the number smaller). So you solve for the best $a_{10}$ such that $$ (a_{100})^2\times 100^2 + \left[ 20 \times (a_{100}\times a_{10}) + (a_{10})^2\right] \times 100 + \leq A $$ The above expression shows why in the first step you want to group the digits in twos: in some sense we are thinking of $A$ as in base-100, the "square" of base-10.

At every step you use the identity $(x+c)^2 = x^2 + 2xc + c^2$ to compute the next digit correction to the square root.


Another method, as the Babylonians did it, was recently detailed by John Baez at his blog, which uses the "equality case" of the arithmetic-mean-geometric-mean inequality to power the iteration.

$\endgroup$
19
$\begingroup$

The best method I know of is the recursive series:$$x_1=b\;\;\;\;\;\;\;\;\;x_{n+1}=\frac{1}{2}\left(x_n+\frac{b}{x_n}\right)$$ It converges very rapidly to $\sqrt{b}$ - for example for b = 3, it is accurate to 7 decimal places after only 4 terms. The long division might not be very easy to carry out strictly with pencil and paper, but it is doable.

$\endgroup$
2
  • $\begingroup$ This answer seems like the simplest one and the one I would be most likely to use when I don't have a calculator handy. $\endgroup$
    – jamesbtate
    Commented Dec 11, 2011 at 22:19
  • $\begingroup$ Yea, certainly seems the most practical. I first saw it on exam question beginning "you're on a desert island with only a 4-fucntion calculator and need to calculate $\sqrt{13}$ $\endgroup$ Commented Dec 11, 2011 at 22:25
7
$\begingroup$

If your number is close enough to a perfect square, you can use the expansion $$ \sqrt{1+x} = 1 + \frac{1}{2}x - \frac{1}{8}x^2 +- \cdots + (-1)^{n-1}\frac{(2n-3)!!}{2\cdot(2n)!!}x^n+\cdots $$ where $$ (2n)!! = (2n)(2n-2)\cdots4\cdot2,\quad(2n+1)!!=(2n+1)(2n-1)\cdots3\cdot1. $$

A famous physist R. Feynman is said to have used this formula and beat an abacus.

$\endgroup$
6
  • 2
    $\begingroup$ @Pteromys: Feynman actually computed the cube root of $1729$, which is nearly $12$. $\endgroup$
    – Ganesh
    Commented Dec 12, 2011 at 0:53
  • $\begingroup$ He'd obviously read Hardy. $\endgroup$ Commented Dec 15, 2011 at 21:27
  • $\begingroup$ So $\sqrt{37}=1+18-162+-...$? $\endgroup$ Commented Jan 31, 2014 at 14:05
  • $\begingroup$ @MichaelHoppe I mean, $\sqrt{36 + 1} = 6\sqrt{1 + 1/36} = 1 + 1/72 -+ \dots$. $\endgroup$
    – Pteromys
    Commented Feb 1, 2014 at 2:48
  • $\begingroup$ @Pteromys Excuse me, please, but I don't understand yet. Would you please be so kind to give me two more summands? Thanks in advance. $\endgroup$ Commented Feb 1, 2014 at 3:24
5
$\begingroup$

This comes from Euler's method in approximating solutions to differential equations. This begins with the fundamental notion that the derivative of f(x)=$x^.5$ is equal to f'(x)=$.5x^{-.5}$. So now it is possible to approximate roots. Take the root of 38. The nearest perfect square is 36. so to approximate the square root of 38, you want to take the square root of 36 and then add $2*.5x^{-.5}$. This gives you $6+1/6$ or 6.166666 repeating, which is a pretty good approximation. If you have more specific questions, just ask.

$\endgroup$
5
$\begingroup$

The general form of Newton's Method for zero-finding is \begin{equation*} x_{k+1} := x_k - \frac{f(x_k)}{f'(x_k)} \end{equation*} The Reciprocal Square Root Newton algorithm is obtained by setting $f(x) = \frac{1}{x^2-a}$ and we get \begin{equation*} x_{k+1} := x_k - \frac{f(x_k)}{f'(x_k)} = x_k - \frac{1/x_k^2-a}{-2/x_k^3}=x_k + \frac{1}{2}x_k(1-ax^2_k). \end{equation*} The sequence $\{x_0,x_1, \ldots, x_k, \ldots\}$ converges quadratically, for all $x_0 >0$, to a fixed point $x$. That is \begin{equation*} x = x + \frac{1}{2}x(1-ax^2), \end{equation*} which has two solutions, $x = 0$, and $x = 1/\sqrt{a}$.

We compute $x_{k+1}$ in two steps:

  1. $e_k := 1-a\star x_k\star x_k $
  2. $x_{k+1} := x_k + e_k\star x_k/2$

Here, $e_k$ is the relative error in $x^2_k,$ i.e., $(1/a-x^2_k)/(1/a)=(1-ax^2_k),$ and $e_kx_k/2$ is the correction term.

The most important aspect of this algorithm is that no divisions are required. The division by 2 can be done by bit-shifting. Calculating $x_{k+1}$ requires 3 Mults and 2 Adds. One final multiplication, $a\star x_k$, is done to calculate $\sqrt{a}$.

If a suitable starting value for $x_0$ is chosen, then this algorithm converges to full IEEE double precision in about 5 iterations. An algorithm similar to this is used by Intel in their Itanium processor, whose basic arithmetic operation is the fused multiply-add (FMA) instruction, $z = ax+y$. All other operations are performed using this FMA instruction. For historical reasons, Intel shies away from long division.

See Peter Markstein, IA-64 and Elementary Functions, Prentice-Hall, 2000

Additional Information

The Reciprocal Newton algorithm is obtained by setting $f(x) = \frac{1}{x-a}$ and we get \begin{equation*} x_{k+1} := x_k - \frac{f(x_k)}{f'(x_k)} = x_k - \frac{1/x_k-a}{-1/x_k^2}=x_k + x_k(1-ax_k). \end{equation*}

We compute $x_{k+1}$ in two steps:

  1. $e_k := 1-a\star x_k $
  2. $x_{k+1} := x_k + e_k\star x_k/2$

Here, $e_k$ is the relative error in $x^2_k,$ i.e., $(1/a-x_k)/(1/a)=(1-ax_k),$ and $e_kx_k/2$ is the correction term. Each of these two steps is calculated by a single FMA instruction. The division, $z = y/x$, is calculated as $y\star\frac{1}{x}$. Note how similar this algorithm is to the reciprocal square root algorithm.

Choosing a starting value $x_0$ for the Reciprocal Algorithm is a delicate matter. It can be shown that the domain of convergence is $ 0 < x_0 < \frac{2}{a}$, but this begs the question: what is $\frac{2}{a}$? This is getting into deep water, so I'll leave the answer to Peter Markstein above.

$\endgroup$
1
$\begingroup$

Just found an interesting way to find square root of a number using Derivatives. All the above answers are awesome, but this method just blew my mind.This method is a trade off between accuracy and time taken to get the result.

Lets take an example. Say $\sqrt{53}$.

Consider $y = \sqrt{x}$ graph

pic2

We have $$y = \sqrt{x}$$ $$dy = \frac{1}{2\sqrt{x}}dx$$

Now, at $x\approx49$ and $dx=4$ $$dy = \frac{1}{2\sqrt{49}}dx$$ $$dy = \frac{2}{7} \approx 0.28$$

Therefore $$\sqrt{53} = 7 + dy = 7.28$$

The results might get a little inaccurate after $\approx$100 because the perfect squares get more sparsely populated and thus making $dx$ comparatively nearer to $x$. Therefore always try to take out all the integers you can from inside the square root and then apply this method on whatever remains inside.

Obviously for this, you need to know the nearest (just less than) perfect square to the given number. But I guess, a little trial and error should get you that perfect square.

$\endgroup$
1
  • 1
    $\begingroup$ This is pretty similar to Newton's method / the Babylonian method. And you can loop it to improve the approximation. Admittedly, the fractions get a bit unwieldy after a few loops, but you can often simplify them by judicious rounding. ;) $$(7+\frac27)^2=49+2×7×\frac27+\frac4{49}=53 \frac4{49}$$ So now you have another perfect square that's much closer to 53, and you can use the derivative again to find an even better approximation. $\endgroup$
    – PM 2Ring
    Commented May 3, 2021 at 8:51
0
$\begingroup$

Scenario: Civilization has crumbled and not only are there no calculators, there are no books. However, our protagonist has a strong understanding of the real number system.

Task: Find the square root of any (positive) number $x$.

Most likely our protagonist will employ a 'divide and conquer' strategy along the lines used by Simon Stevin. Or they might discover the Babylonian_method.

It all comes down to what properties of the real numbers you can employ.

I've recently been looking at the real numbers in a somewhat unorthodox fashion; see

A well-defined binary operation on a class of functions (Eudoxus magnitudes) from $\mathbb N$ to $\mathbb N$?

But, for me it is easy to remember - all I have to do is find the greatest integer less that or equal to $\sqrt x$ and then 'turn the crank'.

Rather than getting into the theory, the next section shows a Python program taking the square roots of $2$. $10.5$ and $37$.

Although it may appear that this is just another 'divide-n-conquer' method, by viewing the real numbers in an 'algorithmic fashion', it is really a 'natural way' to 'walk to the solution'.


# sqrt of a number

import math

while True:
    daNum = int(input('Number you want the square root of = '))
    print("the actual square root of", daNum, "=", daNum**(.5))

    a = math.floor(daNum**(.5))
    n = 0
    maybeOver_boolean = False
    for run in range(0, 25):
        if maybeOver_boolean:
            print(a/2**n, maybeOver_approx)
        else:
             print(a/2**n, '?')
        n = n + 1
        tmp = 2*a
        maybeOver_approx = (tmp+1)/2**n
        if maybeOver_approx**2 < daNum:
            a = tmp + 1
            maybeOver_boolean = False
        else:
            a = tmp
            maybeOver_boolean = True

OUTPUT:

Number you want the square root of = 2
the actual square root of 2.0 = 1.4142135623730951
1.0 ?
1.0 1.5
1.25 ?
1.375 ?
1.375 1.4375
1.40625 ?
1.40625 1.421875
1.4140625 ?
1.4140625 1.41796875
1.4140625 1.416015625
1.4140625 1.4150390625
1.4140625 1.41455078125
1.4140625 1.414306640625
1.4141845703125 ?
1.4141845703125 1.41424560546875
1.4141845703125 1.414215087890625
1.4141998291015625 ?
1.4142074584960938 ?
1.4142112731933594 ?
1.4142131805419922 ?
1.4142131805419922 1.4142141342163086
1.4142131805419922 1.4142136573791504
1.4142134189605713 ?
1.4142135381698608 ?
1.4142135381698608 1.4142135977745056
Number you want the square root of = 10.5
the actual square root of 10.5 = 3.24037034920393
3.0 ?
3.0 3.5
3.0 3.25
3.125 ?
3.1875 ?
3.21875 ?
3.234375 ?
3.234375 3.2421875
3.23828125 ?
3.240234375 ?
3.240234375 3.2412109375
3.240234375 3.24072265625
3.240234375 3.240478515625
3.2403564453125 ?
3.2403564453125 3.24041748046875
3.2403564453125 3.240386962890625
3.2403564453125 3.2403717041015625
3.2403640747070312 ?
3.240367889404297 ?
3.2403697967529297 ?
3.2403697967529297 3.240370750427246
3.240370273590088 ?
3.240370273590088 3.240370512008667
3.240370273590088 3.2403703927993774
3.2403703331947327 ?
Number you want the square root of = 37
the actual square root of 37.0 = 6.082762530298219
6.0 ?
6.0 6.5
6.0 6.25
6.0 6.125
6.0625 ?
6.0625 6.09375
6.078125 ?
6.078125 6.0859375
6.08203125 ?
6.08203125 6.083984375
6.08203125 6.0830078125
6.08251953125 ?
6.08251953125 6.082763671875
6.0826416015625 ?
6.08270263671875 ?
6.082733154296875 ?
6.0827484130859375 ?
6.082756042480469 ?
6.082759857177734 ?
6.082761764526367 ?
6.082761764526367 6.082762718200684
6.082762241363525 ?
6.0827624797821045 ?
6.0827624797821045 6.082762598991394
6.0827624797821045 6.082762539386749
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .