#square roots

56 messages · Page 1 of 1 (latest)

winter skiff
civic templeBOT
#
  1. Wait patiently for a helper to come along.
  2. Once someone helps you, say thank you and close the thread with:
+close
  1. Feel free to nominate the person for helper of the week in #helper-nominations
  2. Do not ping the mods, unless someone is breaking the rules.
  3. If you're happy with the help you got here, and the server overall, you can contribute financially as well:
winter skiff
#

i believe you're supposed to make pairs but what do we do if theres an extra number??

thin oriole
winter skiff
#

it's in decimals

#

can you tell me the next step??

thin oriole
winter skiff
thin oriole
winter skiff
#

the value yeah

thin oriole
#

Oh, alright.
There are several methods of approximating square roots. The easiest one is Newton's method. Have you heard about it?

winter skiff
#

nope

thin oriole
#

Alright. Here's the general approach.
Suppose we want to find √(n).
First, we find the integer closest to it. Let's call it x(0).
Then we iterate:
x(k + 1) = (1/2)(x(k) + n/x(k))
The more times we iterate, the better the approximation. Convergence is quite quick.

#

Do you want to look at √(2000), or should I show it on another example so you can try √(2000) yourself?

winter skiff
#

another example yeah

thin oriole
thin oriole
winter skiff
#

uhh

#

5000

thin oriole
#

Alright.

#

5000 is between 4900 and 5041, closer to the latter. So, the closest integer to √(5000) is 71.
We take x(0) = 71. Then we iterate. I will also calculate the step error at each term: let's stop when it hits 10^(-3).
Step 1.
x(1) = (1/2)(x(0) + 5000/x(0)) = (1/2)(71 + 5000/71) = 10041/142
Δx(1) = |x(1) - x(0)| = |10041/142 - 71| ≈ 0.29
Step 2.
x(2) = (1/2)(x(1) + 5000/x(1)) = (1/2)(10041/142 + 710000/10041) = 201641681/2851644
Δx(2) = |x(2) - x(1)| = |201641681/2851644 - 10041/142| ≈ 6*10^(-4)
We've already hit a value of step error less than 10^(-3) in just two iterations. Thus, we get √(5000) ≈ 201641681/2851644.

winter skiff
#

are 4900 and 5041 the closest perfect squares?

thin oriole
#

If you're interested, the true relative error of that result is |201641681/(2851644√(5000)) - 1| ≈ 3*10^(-11). So, just in those two iterations we've already got an approximation that is so very close.

thin oriole
winter skiff
#

you said it was the simplest method but all those numbers are giving me a headache😭

thin oriole
#

Well, but note that even though the denominator is 7 digits long, we get 10 correct decimal digits.

#

So, 3 more than with a naive decimal approximation.

#

Note that for such round numbers you can modify the method a bit.

#

Notice that √(5000) = 50√(2).

#

So, instead, we can try approximating √(2), then multiplying the result by 50.

winter skiff
#

1.5?

thin oriole
#

The error will be slightly larger, but the numbers will be smaller.

winter skiff
#

actually no wait

thin oriole
winter skiff
#

the root of 1 is 1 itself right?

thin oriole
#

Well, yeah. But I meant that to approximate √(2), we take x(0) = 1, then iterate.

#

Actually, let's try doing that.

#

We'll even take a smaller error margin: 10^(-5), just to account for the fact that we need to multiply the result by 50.

#

We are approximating √(2), so we take x(0) = 1.
Step 1.
x(1) = (1/2)(x(0) + 2/x(0)) = (1/2)(1 + 2/1) = 3/2
Δx(1) = |x(1) - x(0)| = |3/2 - 1| ≈ 0.5
Step 2.
x(2) = (1/2)(x(1) + 2/x(1)) = (1/2)(3/2 + 4/3) = 17/12
Δx(2) = |x(2) - x(1)| = |17/12 - 3/2| ≈ 0.083
Step 3.
x(3) = (1/2)(x(2) + 2/x(2)) = (1/2)(17/12 + 24/17) = 577/408
Δx(3) = |x(3) - x(2)| = |577/408 - 17/12| ≈ 0.0025
Step 4.
x(4) = (1/2)(x(3) + 2/x(3)) = (1/2)(577/408 + 816/577) = 665857/470832
Δx(4) = |x(4) - x(3)| = |665857/470832 - 577/408| ≈ 2.1*10^(-6)
We've hit the step size less than 10^(-5). The approximation we got is √(2) ≈ 665857/470832.
Thus, √(5000) = 50√(2) ≈ 16646425/235416. The relative error this time is |16646425/(235416√(5000)) - 1| = 1.1*10^(-12).

#

Even more than the last time.

#

So, we've got an approximation that gives one more correct digit, despite its denominator being smaller.

#

So, now care to try it for your √(2000)?

#

You can try approximating it as is, or using √(2000) = 20√(5).

#

Personally, I would do it using the second approach.

winter skiff
#

is this how you do it?@thin oriole

#

i'm sorry it took me a while to figure out😭

thin oriole
#

So, I recommend taking x(0) = 45 here.

winter skiff
#

so the closer the approximation is, the closer our answer will be to the actual root?

thin oriole
#

Note that you will eventually reach arbitrary precision with any initial approximation, but it's obviously better to take a closer initial approximation, as you will converge faster that way.

winter skiff
#

thank you

#

i got it

#

+close