0% found this document useful (0 votes)
76 views4 pages

Homework Set No. 5, Numerical Computation: 1. Bisection Method

The document describes several numerical methods for finding roots of functions, including the bisection method, fixed point iteration, Newton's method, and the secant method. It provides examples of applying each method to solve different equations, along with questions about how the methods work and whether they converge. Students are asked to implement Newton's method and the secant method in MATLAB, test them on sample problems, and submit their code.

Uploaded by

kelbmuts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views4 pages

Homework Set No. 5, Numerical Computation: 1. Bisection Method

The document describes several numerical methods for finding roots of functions, including the bisection method, fixed point iteration, Newton's method, and the secant method. It provides examples of applying each method to solve different equations, along with questions about how the methods work and whether they converge. Students are asked to implement Newton's method and the secant method in MATLAB, test them on sample problems, and submit their code.

Uploaded by

kelbmuts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Homework Set No.

5, Numerical Computation
1. Bisection method

We consider the bisection method to find a root for f (x) = 0. If f (0) < 0 and f (1) > 0,
then there is a root on the interval [0, 1], and we take [0, 1] as the initial interval. How
many steps of the bisection method are needed to obtain an approximation to the root,
if the absolute error is ≤ 10−8 ? (Note that this number does not depend on the actual
function!)

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 = g1 (x), where g1 (x) = f (x) + x.

Set up a corresponding fixed point iteration scheme. Then, choose a starting point
x0 = 1.6, and do 4 iterations to compute the values x1 , x2 , x3 , x4 . What do you
observe? Does the method converge? Why?

(c). We observe that f (x) = 0 is also equivalent to

x = g2 (x), where g2 (x) = x − f (x).

Based on this new function, set up the corresponding fixed point iteration. Then,
choose the starting point x0 = 1.6, and do 4 iterations to compute the values
x1 , x2 , x3 , x4 . What is your result? How different is it from part (b)? Does the
method converge? Why?

3. More on fixed point iteration.

Consider the iteration scheme:


1 1
xn+1 = xn + , x0 = 1
2 xn

(a). What is limn→∞ xn if the iteration converges?

(b). Does the method converge? Why?

1
4. Newton’s method

As you have seen in the lecture, the computation of R can be done by finding the root
of f (x) = x2 − R with Newton’s method.

a). Verify that the iteration scheme would be


 
1 R
xn+1 = xn + .
2 xn

b). Show that the sequence {xn } satisfies the following


2
x2 − R

x2n+1 −R = n .
2xn
Interpret this equation in terms of quadratic convergence.

c). Now we test the iterations for R = 10. Choose x0 = 3, and compute x1 , x2 x3 and
x4 . Use 8 digit in your computation. Comment on your result.

5. More on Newton’s method, where it does not work well.

Let m be a positive integer and consider the function

f (x) = (x − 1)m .

It is clear that r = 1 is a root (actual it is a root with multiplicity m).


We now try to find this root by Newton’s iteration, for m = 8.

(a). Set up the iteration.

(b). Now use the initial guess x0 = 1.1 (note that this is very close to the root r = 1).
Complete 4 iterations to compute the values x1 , x2 , x3 , x4 .

(c). How does the method work for this problem? Can you explain why?

(d). If we have m = 20, or for m with large value, could you predict the behavior of
Newton’s iteration? Explain in detail.

6. The secant method

a). Calculate an approximate value for 43/4 using the secant method with x0 = 3 and
x1 = 2. Make 3 steps, and compute the values x2 , x3 , x4 . Comment on your result.

b). Use secant method to find the root for f (x) = x3 − 2x + 1 with x0 = 4 and x1 = 2.
Compute the values x2 , x3 and x4 . Does the method converge? (You can easily
check that x = 1 is a root.)

2
c). Consider an iteration scheme

xn+1 = xn + (2 − exn )(xn − xn−1 )/(exn − exn−1 ), x0 = 0, x1 = 1.

What is limn→∞ xn if the iteration converges?

7. 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 mynewton.m
should start with:

function x=mynewton(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.

First, test your function with the example we had in class, computing 2. Then, use
your Matlab function to find a root of f (x) = e−x − cos(x) on the interval [1.1, 1.6]. Use
tol=1e-12 and nmax=10. You should choose an initial guess x0 on the interval [1.1, 1.6].
What is your answer?
What to hand in: Print out your files mynewton.m,
√ files for functions f (x) and f ′ (x),
script file, test result for the example of 2 and for the root of f (x) = e−x − cos(x).

8*. Matlab problem: the secant method (Bonus 5 points)

Write a Matlab function to locate a root by secant method. Your function should be
put in the file mysecant.m, and should be called as

x=mysecant(f,x0,x1,tol,nmax)

Here f is the function f , x0,x1 are the initial guesses, tol is the error tolerance, nmax
is the maximum number of iterations, and x is the output of your function.

3

Test your function to find the value 2, as the root for f (x) = x2 − 2, to see if it works.
Use sprintf and “disp” to display your result in each iteration, so you can check the
convergence.
Then, use it to find a root for the function f (x) = e−x − cos(x) in the interval [1.1, 1.6].
Use tol=1e-12 and nmax=10. How does the result compare to those with Newton’s
method? Comment in detail.

What to hand in: print out your file mysecant.m, test result for f (x) = x2 − 2, and
the result for f (x) = e−x − cos(x).

You might also like