Docsity

Solutions to Math 151A Homework Problems: Bisection Method and Newton's Method, Assignments of Mathematics

Toggle sidebar
bg1
Homework 1 Solutions
Igor Yanovsky (Math 151A TA)
Problem 1: Determine a formula which relates the number of iterations, n, required
by the bisection method to converge to within an absolute error tolerance of ε, starting
from the initial interval (a, b).
Solution: The bisection method generates a sequence {pn}approximating a root p
of f(x) = 0 with
|pn−p|≤b−a
2n.
To converge to within an absolute error tolerance of εmeans we need to have |pn−p|≤ε,
or
b−a
2n≤ε. (1)
Solving (1), we obtain:
2n≥b−a
ε,
nlog 2 ≥log b−a
ε,
n≥log b−a
ε
log 2 .X
To get some intuition, plug in a=0,b= 1, and ε=0.1. Then, we would get
n>=3.3219. Thus, n= 4 iterations would be enough to obtain a solution pnthat is
at most 0.1 away from the correct solution. Note that dividing the interval [0,1] three
consecutive times would give us a subinterval of 0.0625 in length, which is smaller than
0.1.
Problem 2: Show that when Newton’s method is applied to the equation x2−a=0,
the resulting iteration function is g(x)= 1
2(x+a/x).
Solution: Consider f(x)=x2−a. Consider Newton’s iteration:
pn+1 =g(pn)=pn−f(pn)
f0(pn).
Thus, for Newton’s iteration, we have
g(x)=x−f(x)
f0(x)=x−x2−a
2x=x2+a
2x=1
2x+a
x.X
1
pf3

Partial preview of the text

Download Solutions to Math 151A Homework Problems: Bisection Method and Newton's Method and more Assignments Mathematics in PDF only on Docsity!

Homework 1 Solutions

Igor Yanovsky (Math 151A TA)

Problem 1: Determine a formula which relates the number of iterations, n, required by the bisection method to converge to within an absolute error tolerance of ε, starting from the initial interval (a, b).

Solution: The bisection method generates a sequence {pn} approximating a root p of f (x) = 0 with

|pn − p| ≤ b − a 2 n^

To converge to within an absolute error tolerance of ε means we need to have |pn−p| ≤ ε, or

b − a 2 n^ ≤ ε. (1)

Solving (1), we obtain:

2 n^ ≥

b − a ε

n log 2 ≥ log

( (^) b − a ε

n ≥

log

( (^) b−a ε

log 2

. X

To get some intuition, plug in a = 0, b = 1, and ε = 0.1. Then, we would get n >= 3.3219. Thus, n = 4 iterations would be enough to obtain a solution pn that is at most 0.1 away from the correct solution. Note that dividing the interval [0, 1] three consecutive times would give us a subinterval of 0.0625 in length, which is smaller than 0 .1.

Problem 2: Show that when Newton’s method is applied to the equation x^2 − a = 0, the resulting iteration function is g(x) = 12 (x + a/x).

Solution: Consider f (x) = x^2 − a. Consider Newton’s iteration:

pn+1 = g(pn) = pn − f (pn) f ′(pn)

Thus, for Newton’s iteration, we have

g(x) = x −

f (x) f ′(x) = x −

x^2 − a 2 x

x^2 + a 2 x

x +

a x

. X

Problem 3: Use the bisection method to find p 3 for f (x) =

x − cos x on [0, 1].

Solution: Since f (0) = − 1 < 0 and f (1) = 0. 46 > 0, there is at least one root of f (x) inside [0, 1]. Set [a 1 , b 1 ] = [0, 1].

p 1 = a 1 + b 1 2

f (0.5) = − 0. 17 < 0.

Since f (p 1 )f (b 1 ) < 0, there is a root inside [p 1 , b 1 ] = [0. 5 , 1]. Set [a 2 , b 2 ] = [0. 5 , 1]. f (a 2 ) < 0, f (b 2 ) > 0.

p 2 = a 2 + b 2 2

f (0.75) = 0. 13 > 0.

Since f (a 2 )f (p 2 ) < 0, there is a root inside [a 2 , p 2 ] = [0. 5 , 0 .75]. Set [a 3 , b 3 ] = [0. 5 , 0 .75].

p 3 =

a 3 + b 3 2

= 0. 625. X

Problem 4: The function f (x) = sin x has a zero on the interval (3, 4), namely, x = π. Perform three iterations of Newton’s method to approximate this zero, using p 0 = 4. Determine the absolute error in each of the computed approximations. What is the apparent order of convergence?

Solution: Consider f (x) = sin x. In the interval (3, 4), f has a zero p = π. Also, f ′(x) = cos x. With p 0 = 4, we have

p 1 = p 0 −

f (p 0 ) f ′(p 0 )

sin(4) cos(4)

p 2 = p 1 − f (p 1 ) f ′(p 1 )

sin(2.8422) cos(2.8422)

p 3 = p 2 − f (p 2 ) f ′(p 2 )

sin(3.1509) cos(3.1509)

The absolute errors are:

e 0 = |p 0 − p| = 0. 8584 , e 1 = |p 1 − p| = 0. 2994 , e 2 = |p 2 − p| = 0. 0093 , e 3 = |p 3 − p| = 2. 6876 × 10 −^7.

The corresponding order(s) of convergence are

k = ln(e 2 /e 1 ) ln(e 1 /e 0 )

ln(0. 0093 / 0 .2994) ln(0. 2994 / 0 .8584)

k =

ln(e 3 /e 2 ) ln(e 2 /e 1 )

ln(2. 6876 × 10 −^7 / 0 .0093) ln(0. 0093 / 0 .2994)

We obtain a better than a 3rd^ order of convergence, which is a better order than the theoretical bound gives us. For Newton’s method, the theoretical bound gives convergence order of 2. 1 (^1) The convergence order of k ensures that e 2 e 1 =

( (^) e 1 e 0

)k .