03.03.2014 Views

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.3. SECANT METHOD 53<br />

The following example problems should illustrate this process of “bootstrapping” via Newton’s<br />

Method.<br />

Example Problem 4.10. Devise a subroutine using only subtraction and multiplication that can<br />

find the multiplicative inverse of an input number z, i.e., can find (1/z) .<br />

Solution: We are tempted to use the linear function f(x) = (1/z) −x. But this is a linear equation<br />

for which Newton’s Method would reduce to x k+1 ← (1/z) . Since the subroutine can only use<br />

subtraction and multiplication, this will not work.<br />

Instead apply Newton’s Method to f(x) = z − (1/x) . The Newton step is<br />

x k+1 ← x k − z − (1/x k)<br />

(<br />

1/x<br />

2<br />

k<br />

) = x k − zx 2 k + x k = x k (2 − zx k ) .<br />

Note this step uses only multiplication and subtraction. The subroutine is given in Algorithm 3.<br />

⊣<br />

Algorithm 3: Algorithm for finding a multiplicative inverse using simple operations.<br />

Input: a number<br />

Output: its multiplicative inverse<br />

invs(z)<br />

(1) if z = 0 throw an error.<br />

(2) Let x ← sign (z) , n ← 0.<br />

(3) while n ≤ 50<br />

(4) Let x ← x (2 − zx) .<br />

(5) Let n ← n + 1.<br />

Example Problem 4.11. Devise a subroutine using only simple operations which computes the<br />

square root of an input number z.<br />

Solution: The temptation is to find a zero for f(x) = √ z − x. However, this equation is linear<br />

in x. Instead let f(x) = z − x 2 . You can easily see that if x is a positive root of f(x) = 0, then<br />

x = √ z. The Newton step becomes<br />

x k+1 ← x k − z − x2 k<br />

−2x k<br />

.<br />

after some simplification this becomes<br />

x k+1 ← x k<br />

2 + z<br />

2x k<br />

.<br />

Note this relies only on addition, multiplication and division.<br />

The final subroutine is given in Algorithm 4.<br />

⊣<br />

4.3 Secant Method<br />

The secant method for root finding is roughly based on Newton’s method; however, it is not<br />

assumed that the derivative of the function is known, rather the derivative is approximated by<br />

the value of the function at some of the iterates, x k . More specifically, the slope of the tangent

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!