This is my favorite trick for approximating sqrt. It even works decently rounding to nearest (optionally even) power of two (computationally dirt cheap) as the point to expand at.
It doesn't give a precise value but it's great when the need for a sqrt comes from needing an upper bound for a buffer size or a partition size to guarantee a particular big-O or anything like that.
You can also use newton-raphson's method (on f(x) = x²-a to find sqrt(a)), which is not very complicated, but can approximate very well within a few iterations!
x² = (a + b)² = a² + 2ab + b² You can take a : your first approximation b : the rest, or the difference And probably a >> b , a much bigger than b , so : x² = (a + b)² ~ a² + 2ab 2ab ~ x² - a² ==> b ~ (x² - a²)/(2a) In this case 144 is a square number just below 150, so x² = 150 x = a+b a² = 144 x² = 150 ~ a² + 2*a*b = 144 + 2*12*b 150 ~ 144 + 24b 6 ~ 24b b ~ 6/24 = 0.25 So x ~ a+b = 12.25 I think it's the same equation for approximation as in the video, but it's another approach, isn't it ?
16 + 267-256/32 ≈ 16.343 There is a simpler way to write it as √(a+b) where a is perfect square. Then the approximate will be = n + b/2n, where n = √a. Actually just a few days ago, I was bored & lazy and just asked chatgpt the same thing
Ah, yes. Actually I derived the same thing through some simple continuous fractions fuckery. You can also put the approximation obtained from the equation, back into the equation, to get a better approximation. Also, the equation can be expressed in a clean way like- √n ≈ (n + s²)/2s Where, s² ≤ n < (s+1)²
Sure, But this has been used in various other settings where computing multiple square roots can be faster by only using this linear approximation (like rendering backgrounds in video games )
Maclaurin series for root(x) isn’t possible. But this is the first order Taylor poly and we could do higher order Taylor polynomials as well but not sure the accuracy they give is worth it.
Ok i got it now thanks everyone This method is mostly good when your slope is ~0, high slope approximation will be give more inaccurate ans Am i correct?
I would love to see you show a visualisation for the generalized version of this like Newton's method of approximation.
Is a good idea.
Thank you for making square roots easier to calculate.
This is my favorite trick for approximating sqrt. It even works decently rounding to nearest (optionally even) power of two (computationally dirt cheap) as the point to expand at.
I'm a nerd so I make it a series every time 😞
It doesn't give a precise value but it's great when the need for a sqrt comes from needing an upper bound for a buffer size or a partition size to guarantee a particular big-O or anything like that.
You can also use newton-raphson's method (on f(x) = x²-a to find sqrt(a)), which is not very complicated, but can approximate very well within a few iterations!
This method is actually very similar to Newton-Raphson
x² = (a + b)² = a² + 2ab + b²
You can take
a : your first approximation
b : the rest, or the difference
And probably a >> b ,
a much bigger than b ,
so :
x² = (a + b)² ~ a² + 2ab
2ab ~ x² - a²
==>
b ~ (x² - a²)/(2a)
In this case 144 is a square number just below 150, so
x² = 150
x = a+b
a² = 144
x² = 150 ~ a² + 2*a*b = 144 + 2*12*b
150 ~ 144 + 24b
6 ~ 24b
b ~ 6/24 = 0.25
So
x ~ a+b = 12.25
I think it's the same equation for approximation as in the video, but it's another approach, isn't it ?
Taylor series when n = 1, x0 = a
P_n(x) = f(x0) + f’(x0) ( x-x0) + ( f’’(x0) ( x - x0)**2 ) /2! + …… +
( f^n(x0) ( x -x0)**n ) /n!
16 + 267-256/32 ≈ 16.343
There is a simpler way to write it as √(a+b) where a is perfect square.
Then the approximate will be = n + b/2n, where n = √a.
Actually just a few days ago, I was bored & lazy and just asked chatgpt the same thing
I get 275. Does it need parentheses?
@@barnowlcom If you put the part of parenthesis inplace of 1, then you don't need it
Ah, yes. Actually I derived the same thing through some simple continuous fractions fuckery.
You can also put the approximation obtained from the equation, back into the equation, to get a better approximation.
Also, the equation can be expressed in a clean way like-
√n ≈ (n + s²)/2s
Where, s² ≤ n < (s+1)²
It is a nice exercise in a calculus class. In general math just use the calculator in your phone.
Sure, But this has been used in various other settings where computing multiple square roots can be faster by only using this linear approximation (like rendering backgrounds in video games )
Can't you just put a McLaurin series and just evaluate it to, like, the fifth/sixth time?
Maclaurin series for root(x) isn’t possible. But this is the first order Taylor poly and we could do higher order Taylor polynomials as well but not sure the accuracy they give is worth it.
@@MathVisualProofs Oh because d/dx[sqrt(x)]=x^(-1/2). That makes sense. :)
@@Somerandomchap :)
Isn't this pretty much the same as using the the two known squares either side of the target as demonstrated in your other video?
I my only doubt is how did you plot the tangent equation?is it a general equation?
Yes it is
The tangent line of a function on a point a is described by the equation :
y = f'(a) (x - a) + f(a)
The tangent line passes through the point (a, f(a)) and has slope given by the derivative, which is f’(a).
Ok i got it now thanks everyone
This method is mostly good when your slope is ~0, high slope approximation will be give more inaccurate ans
Am i correct?
newtons method and eulers method are better to approx.
Make sense
a