Approximate Square Roots with Calculus!

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ • 28

  • @frendlyleaf6187
    @frendlyleaf6187 20 годин тому +23

    I would love to see you show a visualisation for the generalized version of this like Newton's method of approximation.

  • @Salamander876
    @Salamander876 21 годину тому +8

    Thank you for making square roots easier to calculate.

  • @daliasprints9798
    @daliasprints9798 22 години тому +9

    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.

    • @jaja47_coolness
      @jaja47_coolness 16 годин тому

      I'm a nerd so I make it a series every time 😞

    • @daliasprints9798
      @daliasprints9798 9 годин тому

      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.

  • @AmitYellin
    @AmitYellin 14 годин тому +4

    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!

    • @coderamen666
      @coderamen666 11 годин тому

      This method is actually very similar to Newton-Raphson

  • @whoff59
    @whoff59 11 годин тому +3

    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 ?

  • @amirammar6687
    @amirammar6687 13 годин тому +4

    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!

  • @cyberawm1158
    @cyberawm1158 23 години тому +9

    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

    • @barnowlcom
      @barnowlcom 23 години тому

      I get 275. Does it need parentheses?

    • @cyberawm1158
      @cyberawm1158 23 години тому +2

      ​@@barnowlcom If you put the part of parenthesis inplace of 1, then you don't need it

    • @krishnachoubey8648
      @krishnachoubey8648 22 години тому

      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)²

  • @danielsaldivar5622
    @danielsaldivar5622 19 годин тому +1

    It is a nice exercise in a calculus class. In general math just use the calculator in your phone.

    • @MathVisualProofs
      @MathVisualProofs  15 годин тому +2

      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 )

  • @Somerandomchap
    @Somerandomchap 12 годин тому +1

    Can't you just put a McLaurin series and just evaluate it to, like, the fifth/sixth time?

    • @MathVisualProofs
      @MathVisualProofs  10 годин тому +1

      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.

    • @Somerandomchap
      @Somerandomchap 8 годин тому +2

      @@MathVisualProofs Oh because d/dx[sqrt(x)]=x^(-1/2). That makes sense. :)

    • @MathVisualProofs
      @MathVisualProofs  8 годин тому

      @@Somerandomchap :)

  • @izzabelladogalini
    @izzabelladogalini 2 години тому

    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?

  • @RohitSingh-rw8cz
    @RohitSingh-rw8cz 19 годин тому +1

    I my only doubt is how did you plot the tangent equation?is it a general equation?

    • @undecorateur
      @undecorateur 16 годин тому +2

      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)

    • @MathVisualProofs
      @MathVisualProofs  15 годин тому +2

      The tangent line passes through the point (a, f(a)) and has slope given by the derivative, which is f’(a).

    • @RohitSingh-rw8cz
      @RohitSingh-rw8cz 7 годин тому

      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?

  • @belv1767
    @belv1767 6 годин тому

    newtons method and eulers method are better to approx.

  • @Fadhw
    @Fadhw 2 години тому

    Make sense

  • @Bang-z7t
    @Bang-z7t 19 годин тому +1

    a