The correct way to calculate the square root of a hand

Source: Internet
Author: User
Tags square root

What is the "correct" way to calculate the square root of a hand? If you think it's Newton's iterative method, you can try it yourself and see how it works:

(The original post kz3007407872, because Baidu posted posts are public, I will not play the code)

In fact, Newton iterative method is very good, on the computer fast to fly. But the hand counts.

So what is the "right" approach? Is this:

(Same as previous)

What is the method of saying that God is so talkative that he can open an infinite number of decimals? I didn't say it in the post.

Fortunately, I happened to turn to this method when I was on the Wiki one day. This method is described in detail in this article.

What is the arithmetic square root of \ (2\)? Yes \ (\sqrt{2}\). Not \ (1.41\), nor \ (1.414213\). Therefore, the calculation discussed in this article is based on (decimal decimal) approximation. To be exact, it is a less approximate value.

Approximate values, either 1-bit or 1000-bit after the decimal point, are approximate. So, to calculate the approximate value, you first have to determine the accuracy (that is, you are satisfied with which one/order of magnitude).

First, we discuss the case where a number is squared, which is exactly 1 digits after the decimal point (in the case of calculation \ (\sqrt{2}\)).

This comes up with a problem: we all know that \ (\sqrt{2}\) is accurate to a decimal is \ (1.4\), but is (1.4\), not \ (1.3\) or \ (1.5\)?

Obviously, \ (1.5^2 > 2\), not the approximate value we want. and \ (1.3^2 < 1.4^2 < 2 \) So in the case of no excess, the nearest (within the given precision range) number is \ (1.4\).

Since that is the case, we can "generalize" the process to solve the problem:

Ask for the largest number of (x\), so that the inequality \ (\overline{1.x}^2 \leqslant 2 \) is established.

After finding \ (x=4\), if you want to continue to improve the accuracy, then solve this problem:

Ask for the largest number of (y\), so that the inequality \ (\overline{1.4y}^2 \leqslant 2 \) is established.

(accuracy can also continue to improve)

......

This is actually the most common method of calculating square root, that is, "test multiply". However, the calculation of the square of \ (\overline{1.x} \) is a multi-digit multiply number, not a good count. And as the accuracy increases, it becomes more and more difficult to calculate (\ (\overline{1.414213x}^2\) What to think about will explode). Since hard calculation is not good, then you need skill. What kind of tricks? We can bashi to reduce the scale of the operation:

\ ((1+\frac{x}{10}) ^2 \leqslant 2 \) (1)

To expand the total square, you have to:

\ (1+\frac{2x}{10}+\frac{x^2}{100} \leqslant 2 \)

\ (\leftrightarrow \frac{2x}{10}+\frac{x^2}{100} \leqslant 1 \)

\ (\leftrightarrow 20x+x^2 \leqslant 100 \)

\ (\leftrightarrow x (20+x) \leqslant 100 \)

\ (\leftrightarrow X\cdot \overline{2x} \leqslant 100 \) (2)

In this way, the scale of the operation is reduced from a multi-digit multiplier to a multiple-digit number, which can be a lot more immediately.

Continue to improve accuracy, to find the number on the percentile (y\):

\ ((1+\frac{x}{10}+\frac{y}{100}) ^2 \leqslant 2 \)

\ (\leftrightarrow {\left [(1+\frac{x}{10}) +\frac{y}{100} \right]}^2 \leqslant 2 \)

\ (\leftrightarrow (1+\frac{x}{10}) ^2+2 (1+\frac{x}{10}) \frac{y}{100}+\frac{y^2}{10000} \leqslant 2 \)

\ (\leftrightarrow 2 (1+\frac{x}{10}) \frac{y}{100}+\frac{y^2}{10000} \leqslant (1+\frac{x}{10}) ^2 \)

\ (\leftrightarrow 2 (1+\frac{x}{10}) \frac{y}{100}+\frac{y^2}{10000} \leqslant (1+\frac{2x}{10}+\frac{x^2}{100}) \ )

\ (\leftrightarrow 2 (1+\frac{x}{10}) \frac{y}{100}+\frac{y^2}{10000} \leqslant (\frac{2x}{10}+\frac{x^2}{100}) \)

\ (\leftrightarrow (10+x) y+y^2 \leqslant \left [100-(20x+x^2) \right] \)

\ (\leftrightarrow y \left [(10+x) +y \right] \leqslant \left [100-x (20+x) \right] \)

\ (\leftrightarrow y (20\cdot \overline{1x}+y) \leqslant \left [100-x\cdot \overline{2x} \right] \)

\ (\leftrightarrow y (2\cdot \overline{1x0}+y) \leqslant \left [100-x\cdot \overline{2x} \right] \)

\ (\leftrightarrow Y\cdot \overline{\overline{(2\cdot\overline{1x})}y} \leqslant \left [100-x\cdot \overline{2x} \ Right] \) (3)

Substituting \ (x=4\) to find out \ (y\):

\ (Y\cdot \overline{28y} \leqslant (100-4\cdot 24) \) (4)

We found that the right side of the (3) formula had the same part as the (2) formula (one side after the move), and this part was also multiplied by \ (100\). and (3) the left side, the same as \ (2\) The left form, are unknown multiplied by the result sequence has been obtained twice times at the end of this unknown (that is, the "number of digits in the post is the number of positions of the number of positions plus 1"). " Now, in fact, can be summed up the law, describe a complete algorithm.

However, some people will not be satisfied at this time:

* *, what do you mean by these crappy formulas? Why do you want to double the results you've got? The inequality on both sides of the previous step, multipliedby the two, and what the hell is the plane?

For this open method, if only using algebra to deduce, it does make people confused. However, the meaning of these steps is very obvious, as one can intuitively illustrate with geometric methods. After reading the following geometrical instructions, you will find that these seemingly "unreasonable" steps are, in fact, justified.

Take a look at this picture (the geometric proof of the full square formula in positive case):

(Source: Original/public Domain)

Look at this picture again:

(Source: Wikipedia)

Did you find anything?

Just calculate the \sqrt{2}\ approximation of the process, in fact, in this area of \ (2\) of the large green square, cut out a side length of \ (\overline{1.4x} \; (x=0,\;1,\;2,\;\cdots 9) \) A small square that makes \ (x\) the largest. And this small square can be divided into four parts by two lines perpendicular to one another. One is the square (blue) of the side length for the 1.4\ (the result of the last bit, i.e. \ ()), and the remaining two rectangles (orange) and a square (pink).

The side length of the whole small square is \ (\overline{1.4x} \), the blue square side length is \ (1.4\), so the width of the orange rectangle is \ (X\cdot 10^{-2} \), Long is \ (1.4\), the pink square side length is \ (X\cdot 10 ^{-2} \).

Now we ask for this percentile, is actually to let the small square in size does not exceed the premise of large square, edge length (area) to reach the maximum. How to ensure that the area does not exceed the large square? We subtract the area of the blue Square from the area of the large square, so that the area of the two orange rectangles and pink squares does not exceed the area difference , i.e.:

\ (2s_{orange}+s_{pink} \leqslant S_{green}-s_{blue} \)

By substituting their values, you get:

\ (2 \times 1.4 \cdot (x \cdot 10^{-2}) + (x \cdot 10^{-2}) ^2 \leqslant 2-1.4^2 \)

\ (\leftrightarrow 2 \times 1.4 \cdot (x \cdot 10^{-2}) + x^2 \cdot 10^{-4} \leqslant 2-1.4^2 \)

\ (\leftrightarrow 2 \times 1.4 \cdot (x \cdot 10^2) + x^2 \leqslant 10^4 (2-1.4^2) \)

\ (\leftrightarrow \times x + x^2 \leqslant 10^4 ((1+0.4) ^2) \)

\ (\leftrightarrow x (280 + x) \leqslant 10^4 ((1+0.8+0.16)) \)

\ (\leftrightarrow x \cdot \overline{28x} \leqslant 10^4 (1-0.96) \)

\ (\leftrightarrow x \cdot \overline{28x} \leqslant 10^4 (1-0.96) \)

\ (\leftrightarrow x \cdot \overline{28x} \leqslant \times (100-96) \)

Is it exactly the same as (4)? So, this explanation, the meaning of those steps is obvious:

    • doubling the last result is equivalent to finding the area of two orange rectangles . In \ (20x+x^2 \leqslant \leftrightarrow x (20+x) \leqslant 100 \) This equation, \ (20x\) is equivalent to the orange part, \ (x^2\) is equivalent to the pink part
    • The poor operation, the equivalent of the total area of the deduction of the blue part of the parts , and then the calculation is then deducted from the accuracy of the increase in the blue has been the area of the increased portion.
    • Multiply It because the new one has reduced an order of magnitude from the previous one, and the extra three blocks are two orders of magnitude less.

Now, let's take the Calculation \ (\sqrt{3} \), \ (\sqrt{65536} \) and \ (\sqrt{\frac{1}{3}} \) as an example to fully describe the algorithm.

Example 1 calculation \ (\sqrt{3} \), accurate to percentile.

First, write the Radicals (one of the two-bit results of radicals) on paper like this:

Find the highest bit value of the result (that is, the maximum number of digits \ (x\), so \ (x^2 \leqslant 3 \)), written in the corresponding position on the horizontal line:

Write \ (x^2\) below this one, draw a horizontal line like a division, and make a difference:

Drag the back of the two-bit number to the back of the calculated difference:

Double the calculated result (if you have a decimal point, remove the decimal point) and write it aside:

Add a horizontal line and a multiplication sign, followed by a horizontal line and a less than equals sign, to get an inequality:

Fill each line with as large a number as possible (the same number on the two horizontal lines), and ensure that the inequalities are true :

Write this one number on top as a result:

Write the results of the multiplication below (7x27=189) and continue the difference:

Repeat the process until the desired accuracy is achieved:

......

Example 2 calculation \ (\sqrt{65536} \).

In contrast to Example 1, this last inequality is exactly equal to the equals sign. To get an equal sign, it means that the result is accurate, no further down.

Example 3 calculation \ (\sqrt{\frac{1}{3}}\), accurate to thousands of bits.

First convert \ (\frac{1}{3}\) to infinite decimal \ (0.333\cdots\), then the root:

As the Post said, the infinite number of decimal, the computation will not increase (and the calculation of the finite fractional steps are exactly the same).

The correct way to calculate the square root of a hand

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.