Docsity

Numerical Computations HW 5: Bisection, Fixed Point, and Newton's Methods, Assignments of Mathematics

Toggle sidebar
bg1
CSE/MATH 451: Numerical Computations, spring 2005,
section 2
Home work 5
Deadline: March 18(Fri) in class.
The problems will be graded selectively. Problems marked with (*) are more
challanging, extra points will be awarded for them.
1 Bisection method
If a= 0 and b= 1, how many steps of the bisection method are needed to determine
the root, if the absolute error is ≤10−8?
2 Fixed point iteration
Given a function f(x) = e−x−cos(x). We want to find a root rsuch that f(r) = 0.
(a). First, show that there is a root in the interval [1.1,1.6].
(b). Now we try to locate this root by fixed point iteration. First, we observe that
f(x) = 0 is equivalent to x=g(x) = f(x) + x. What is your iteration scheme?
Let x0= 1.6, and do 4 iterations to compute x1, x2, x3, x4. What is your result?
Does the method converge? Why?
(c). We observe that f(x) = 0 is also equivalent to x=g(x) = x−f(x). What is your
iteration scheme? Let x0= 1.6, and do 4 iterations to compute x1, x2, x3x4. What
is your result? Does the method converge? Why?
(d). Consider the iteration scheme: xn+1 =1
2xn+1
xnwith initial value x0= 1. What
is limn→∞ xnif it converges? Does the method converge? Why?
3 Newton’s method
As you have seen at the lecture, the computation of √Rcan be done by finding the root
of f(x) = x2−R= 0 with Newton’s method.
a). Verify that the iteration scheme would be
xn+1 =1
2xn+R
xn.
1
pf2

Partial preview of the text

Download Numerical Computations HW 5: Bisection, Fixed Point, and Newton's Methods and more Assignments Mathematics in PDF only on Docsity!

CSE/MATH 451: Numerical Computations, spring 2005,

section 2

Home work 5

Deadline: March 18(Fri) in class. The problems will be graded selectively. Problems marked with (*) are more challanging, extra points will be awarded for them.

1 Bisection method

If a = 0 and b = 1, how many steps of the bisection method are needed to determine the root, if the absolute error is ≤ 10 −^8?

2 Fixed point iteration

Given a function f (x) = e−x^ − cos(x). We want to find a root r such that f (r) = 0.

(a). First, show that there is a root in the interval [1. 1 , 1 .6].

(b). Now we try to locate this root by fixed point iteration. First, we observe that f (x) = 0 is equivalent to x = g(x) = f (x) + x. What is your iteration scheme? Let x 0 = 1.6, and do 4 iterations to compute x 1 , x 2 , x 3 , x 4. What is your result? Does the method converge? Why?

(c). We observe that f (x) = 0 is also equivalent to x = g(x) = x − f (x). What is your iteration scheme? Let x 0 = 1.6, and do 4 iterations to compute x 1 , x 2 , x 3 x 4. What is your result? Does the method converge? Why?

(d). Consider the iteration scheme: xn+1 = 12 xn + (^) x^1 n with initial value x 0 = 1. What is limn→∞ xn if it converges? Does the method converge? Why?

3 Newton’s method

As you have seen at the lecture, the computation of

R can be done by finding the root of f (x) = x^2 − R = 0 with Newton’s method.

a). Verify that the iteration scheme would be

xn+1 =

( xn +

R

xn

) .

Show that the sequence {xn} satisfies the following

x^2 n+1 − R =

[ x^2 n − R 2 xn

] 2 .

Interpret this equation in terms of quadratic convergence.

b). Now we test the iterations for R = 10. Choose x 0 = 3, and compute x 1 , x 2 x 3 and x 4. Use 8 digit in your computation. What is your result?

4 More on Newton’s method*(extra 10 points)

It is clear that f (x) = (x − 1)m^ has a root at r = 1 for any positive integer m. Compute this root by Newton’s method for m = 8, use x 0 = 1.1(which is very close to the root). Do 4 iterations to get x 1 , x 2 , x 3 , x 4. Does the method work well here? Can you explain why?

5 The secant method

If we use secant method on f (x) = x^3 − 2 x + 1 with x 0 = 4 and x 1 = 2, what is x 2 , x 3 and x 4? Does the method converge? (You can easily check that x = 1 is a root.)

6 Matlab problem: Newton’s method

Preparation: Use “help sprintf” and “help disp” in Matlab to understand how to use “sprintf” and “disp” to display the data. Here is an example:

disp(sprintf(’I have n=%d and x=%g but f=%f.\n’,2,1.22, 1.22))

This will give the following result in Matlab:

I have n=2 and x=1.22 but f=1.220000.

The problem: Write a Matlab function for Newton’s method. Your file newton.m should start with:

function x=newton(f,df,x0,tol,nmax)

where f,df are the function f and its derivative f ′, x0 is the initial guess, tol is the error tolerance, nmax is the maximum number of iterations, and x is the result. Use sprintf and “disp” to display your result in each iteration so you can check the convergence along the way. Test your function with the example 7 on page 37 in text book. Find a root of f (x) = e−x^ − cos(x) in the interval [1. 1 , 1 .6] with your Matlab function. Use tol=1e-12 and nmax=10. What is your answer?

What to hand in: Print out your files newton.m, files for functions f (x) and f ′(x), test results for the example in the book, and the result for f (x) = e−x^ − cos(x).