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.

58 CHAPTER 4. FINDING ROOTS<br />

Exercises<br />

(4.1) Consider the bisection method applied to find the zero of the function f(x) = x 2 − 5x + 3,<br />

with a 0 = 0, b 0 = 1. What are a 1 , b 1 ? What are a 2 , b 2 ?<br />

(4.2) Approximate √ 10 by using two steps of Newton’s method, with an initial estimate of x 0 = 3.<br />

(cf. Example Problem 4.11) Your answer should be correct to 5 decimal places.<br />

(4.3) Consider bisection for finding the root to cos x = 0. Let the initial interval I 0 be [0, 2]. What<br />

is the next interval considered, call it I 1 ? What is I 2 ? I 6 ?<br />

(4.4) What does the sequence defined by<br />

x 0 = 1,<br />

x k+1 = 1 2 x k + 1 x k<br />

converge to?<br />

(4.5) Devise a subroutine using only simple operations that finds, via Newton’s Method, the cubed<br />

root of some input number z.<br />

(4.6) Use Newton’s Method to approximate 3√ 9. Start with x 0 = 2. Find x 2 .<br />

(4.7) Use Newton’s Method to devise a sequence x 0 , x 1 , . . . such that x k → ln 10. Is this a reasonable<br />

way to write a subroutine that, given z, computes ln z? (Hint: such a subroutine would require<br />

computation of e x k. Is this possible for rational x k without using a logarithm? Is it practical?)<br />

(4.8) Give an example (graphical or analytic) of a function, f(x) for which Newton’s Method:<br />

(a) Does not find a root for some choices of x 0 .<br />

(b) Finds a root for every choice of x 0 .<br />

(c) <strong>Fall</strong>s into a cycle for some choice of x 0 .<br />

(d) Converges slowly to the zero of f(x).<br />

(4.9) How will Newton’s Method perform for finding the root to f(x) = √ |x| = 0?<br />

(4.10) Implement the inverse finder described in Example Problem 4.10. Your m-file should have<br />

header line like:<br />

function c = invs(z)<br />

where z is the number to be inverted. You may wish to use the builtin function sign. As<br />

an extra termination condition, you should have the subroutine return the current iterate if<br />

zx is sufficiently close to 1, say within the interval (0.9999, 0.0001). Can you find some z for<br />

which the algorithm performs poorly?<br />

(4.11) Implement the bisection method in octave/Matlab. Your m-file should have header line like:<br />

function c = run_bisection(f, a, b, tol)<br />

where f is the name of the function. Recall that feval(f,x) when f is a string with the<br />

name of some function evaluates that function at x. This works for builtin functions and<br />

m-files.<br />

(a) Run your code on the function f(x) = cos x, with a 0 = 0, b 0 = 2. In this case you can<br />

set f = "cos".<br />

(b) Run your code on the function f(x) = x 2 − 5x + 3, with a 0 = 0, b 0 = 1. In this case you<br />

will have to set f to the name of an m-file (without the “.m”) which will evaluate the<br />

given f(x).<br />

(c) Run your code on the function f(x) = x − cos x, with a 0 = 0, b 0 = 1.<br />

(4.12) Implement Newton’s Method. Your m-file should have header line like:<br />

function x = run_newton(f, fp, x0, N, tol)<br />

where f is the name of the function, and fp is its derivative. Run your code to find zeroes of<br />

the following functions:<br />

(a) f(x) = tan x − x.

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

Saved successfully!

Ooh no, something went wrong!