1.1.7 Example: Square Roots by Newton's Method Flashcards
The contrast between mathematical functions and computer procedures is a reflection of
The general distinction between describing the properties of things and describing how to do things, or, the distinction between declarative knowledge and imperative knowledge.
In mathematics, we are usually concerned with declarative (what is) descriptions whereas in computer science, we are usually concerned with imperative (how to) descriptions.
The most common way to compute square roots
Newton’s method of successive approximation
Newton’s method of successive approximation
Whenever we have a guess y for the value of the square root of a number x, we can perform simple manipulation to get a better guess (one closer to the actual square root) by averaging y with x/y.
For example, we can compute the square root of 2 as follows. Suppose our initial guess is 1:
Guess, Quotient, Average
1, (2/1) = 2, ((2 + 1)/2) = 1.5
1.5, (2/1.5) = 1.3333, ((1.3333 + 1.5)/2) = 1.4167
1.4167, (2/1.4167) = 1.4118, (1.4167 + 1.4118)/2) = 1.4142
1.4142 … …
Continuing this process, we obtain better and better approximations of the square root.
radicant
the number whose square root we are trying to compute