Calculating Square Roots - Matrix Algorithm

Click For Summary

Homework Help Overview

The discussion revolves around an algorithm for calculating square roots using matrix methods. The original poster introduces a technique involving approximations and matrix multiplication to iteratively refine the estimate of the square root of a number, n. Participants explore the mathematical properties of this method and its convergence behavior.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning

Approaches and Questions Raised

  • Participants discuss the matrix method for approximating square roots and its iterative nature. Questions arise about the mathematical justification for the method's effectiveness and the concept of fixed points in relation to the iterative process.

Discussion Status

The conversation has led to insights about fixed points and stability in the context of the discussed algorithm. Some participants have provided mathematical explanations and references to relevant theorems, while others express curiosity about the underlying principles without reaching a consensus on the method's broader implications.

Contextual Notes

Participants note the method's reliance on initial approximations and the iterative nature of the process. There is also mention of the stability of fixed points and the conditions under which the method converges, particularly in relation to the eigenvalues of the associated matrix.

danago
Gold Member
Messages
1,118
Reaction score
4
Hi. I only just recently found out about an algorithm for calculating the square roots of a number.

Lets say i want to evaluate [tex]\sqrt {n}[/tex]. I can make an approximation by inspection, and say [tex]\sqrt n \approx \frac{a}{b}[/tex]. Now, using this approximation, i can write:

[tex] \left[ {\begin{array}{*{20}c}<br /> 1 & n \\<br /> 1 & 1 \\<br /> \end{array}} \right]\left[ {\begin{array}{*{20}c}<br /> a \\<br /> b \\<br /> \end{array}} \right] = \left[ {\begin{array}{*{20}c}<br /> {a + bn} \\<br /> {a + b} \\<br /> \end{array}} \right][/tex]

Treating the resultant matrix as a fraction ([tex] \frac{{a + bn}}{{a + b}}[/tex]
), i have a better approximation of [tex]\sqrt {n}[/tex]. If i keep repeating this method with the new approximation, over and over again, i get a more accurate answer. So the next step would be:

[tex] \left[ {\begin{array}{*{20}c}<br /> 1 & n \\<br /> 1 & 1 \\<br /> \end{array}} \right]\left[ {\begin{array}{*{20}c}<br /> {a + bn} \\<br /> {a + b} \\<br /> \end{array}} \right] = \left[ {\begin{array}{*{20}c}<br /> {a + an + 2bn} \\<br /> {2a + b + bn} \\<br /> \end{array}} \right][/tex]

And [tex] \frac{{a + an + 2bn}}{{2a + b + bn}}[/tex] would be an even better approximation to [tex]\sqrt {n}[/tex].

Even if the starting approximation is way off, if a lot of iterations are complete, the answer will still be accurate.


Im just wondering, why does this method work? Is there a name for this method, or anywhere i can look to find more information?

Thanks,
Dan.
 
Physics news on Phys.org
That sure seems like a complex method.

A Newton's method root finder yields a very simple iterative method:

[tex]x_{n+1} = \frac 1 2 (x_n + \frac A {x_n})[/tex]

So A is the number you are computing the root of and [itex]x_0[/itex] is your inital guess, it doesn't have to be very good. Compute [itex]x_1[/itex] with the formula, continue.

This procedure converges quadratically.
 
Hmm that method does seem good. I am still interested in the matrix method though. I am not interested in it as a way to actually calculate square roots, but as a mathematical phenomenon. Just curious as to why it works.

Ofcouse I am still always going to resort to my calculator to evaluate them :)
 
well, you are essentially taking an initial value of x, and then iterate through
[tex]x_{i+1}=\frac{x_{i}+n}{x_{i}+1}[/tex]
so, let
[tex]f(x)=\frac{x+n}{x+1}[/tex]
the fix point of f
[tex]f(x)=x[/tex]
is sqrt(n)

you can check derivatives and find out when this fix point is asymptotically stable.
 
tim_lou said:
well, you are essentially taking an initial value of x, and then iterate through
[tex]x_{i+1}=\frac{x_{i}+n}{x_{i}+1}[/tex]
so, let
[tex]f(x)=\frac{x+n}{x+1}[/tex]
the fix point of f
[tex]f(x)=x[/tex]
is sqrt(n)

you can check derivatives and find out when this fix point is asymptotically stable.

Yep, i understand that i am essentially iterating through [tex]x_{i+1}=\frac{x_{i}+n}{x_{i}+1}[/tex], but what do you mean when you say 'fix point'?
 
Just researched it on wikipedia, and now understand what a fixed point is.

[tex] \begin{array}{l}<br /> f(x) = \frac{{x + n}}{{x + 1}} \\ <br /> \frac{{x + n}}{{x + 1}} = x \\ <br /> x^2 + x = x + n \\ <br /> x^2 = n \\ <br /> x = \sqrt n \\ <br /> \end{array}[/tex]

That pretty much exactly answers my question. Thanks very much for that
 
hehe, if you want to dig deep. Do you know why this works for All n?

well, the reason, is, the absolute value of f'(x) at the fixed point is less than 1 for all n except n=0. there is a theorem that says (from my difference equation book)

if x* is a fix point for f and f is continuously differentiable at x* then
(1) if |f'(x*)| < 1, then x* is asymptotically stable.
(2) if |f'(x*)| > 1, then x* is unstable.

so that in your case, x* is asymptotically stable.

what if |f'(x*)|=0? then you need to do a lot more tests... if you want to know more. go to the library and pick up a difference equation book...
 
The analysis is a lot easier in the case of multiplying by a matrix. :smile:

The eigenvalues of the matrix

[tex] \left[ {\begin{array}{*{20}c}<br /> 1 & n \\<br /> 1 & 1 \\<br /> \end{array}} \right][/tex]

are

[tex]1 \pm \frac{\sqrt{n}}{2}[/tex]

If you take (almost) any vector and repeatedly multiply by the matrix A, the result will approach the eigenspace associated to the largest eigenvalue in magnitude. Here, that's [itex]1 + \sqrt{n} / 2[/itex].


Given the rest of the discussion, I expect that the eigenspace associated to the eigenvalue [itex]1 + \sqrt{n} / 2[/itex] is the set of all:

[tex] a <br /> \left[ {\begin{array}{c}<br /> \sqrt{n} \\ 1<br /> \end{array}} \right][/tex]

In fact, I would go so far as to expect A to factor as:

[tex] <br /> \left[ {\begin{array}{cc}<br /> 1 & n \\<br /> 1 & 1 \\<br /> \end{array}} \right]<br /> =<br /> \left[ {\begin{array}{cc}<br /> \sqrt{n} & -\sqrt{n} \\<br /> 1 & 1 \\<br /> \end{array}} \right]<br /> \left[ {\begin{array}{cc}<br /> 1 + \frac{\sqrt{n}}{2} & 0 \\<br /> 0 & 1 - \frac{\sqrt{n}}{2} \\<br /> \end{array}} \right]<br /> <br /> \left[ {\begin{array}{cc}<br /> \sqrt{n} & -\sqrt{n} \\<br /> 1 & 1 \\<br /> \end{array}} \right]^{-1}<br /> [/tex]
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 21 ·
Replies
21
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K