Docsity

Root-Finding Methods: Bisection, Newton's Method, and Secant Method, Exams of Mathematics

Toggle sidebar
bg1
Midterm Review
Igor Yanovsky (Math 151A TA)
1 Root-Finding Methods
Rootfinding methods are designed to find a zero of a function f, that is, to find a value of
xsuch that
f(x)=0.
1.1 Bisection Method
To apply Bisection Method, we first choose an interval [a, b] where f(a) and f(b) are of
different signs. We define a midpoint
p=a+b
2.
If f(p) = 0, then pis a root and we stop.
Else if f(a)f(p)<0, then a root lies in [a, p], and we assign b=p. Otherwise, a=p.
We then consider this new interval [a, b], and repeat the procedure.
The formula for midpoint above generates values pn. We can bound an error of each
iterate pnfor the bisection method:
|pn−p|=b−a
2n.
Note, as n→∞,pn→p.
Practice Problem: The function f(x)=sinxsatisfies f(−π/2) = −1 and f(π/2) = 1.
Using bisection method, how many iterations are needed to find an interval of length at
most 10−4which contains a root of a function?
Solution: We need to find nsuch that:
b−a
2n≤10−4.
We have
π
2n≤10−4.
2n≥π
10−4,
2n≥π104,
nlog 2 ≥log(π104),
n≥log π104
log 2 =14.94.
That is, n= 15 iterations are needed to find an interval of length at most 10−4which
contains the root.
See Problems 1 and 3 in Homework 1 for other examples of bisection method.
1
pf3
pf4
pf5

Partial preview of the text

Download Root-Finding Methods: Bisection, Newton's Method, and Secant Method and more Exams Mathematics in PDF only on Docsity!

Midterm Review

Igor Yanovsky (Math 151A TA)

1 Root-Finding Methods

Rootfinding methods are designed to find a zero of a function f , that is, to find a value of x such that

f (x) = 0.

1.1 Bisection Method

To apply Bisection Method, we first choose an interval [a, b] where f (a) and f (b) are of different signs. We define a midpoint

p =

a + b 2

If f (p) = 0, then p is a root and we stop. Else if f (a)f (p) < 0, then a root lies in [a, p], and we assign b = p. Otherwise, a = p. We then consider this new interval [a, b], and repeat the procedure.

The formula for midpoint above generates values pn. We can bound an error of each iterate pn for the bisection method:

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

Note, as n → ∞, pn → p.

Practice Problem: The function f (x) = sin x satisfies f (−π/2) = −1 and f (π/2) = 1. Using bisection method, how many iterations are needed to find an interval of length at most 10−^4 which contains a root of a function?

Solution: We need to find n such that: b − a 2 n^

≤ 10 −^4.

We have π 2 n^

≤ 10 −^4.

2 n^ ≥ π 10 −^4

2 n^ ≥ π 104 , n log 2 ≥ log(π 104 ),

n ≥

log

π 104

log 2

That is, n = 15 iterations are needed to find an interval of length at most 10−^4 which contains the root. See Problems 1 and 3 in Homework 1 for other examples of bisection method.

1.2 Newton’s Method

The Newton’s iteration is defined as:

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

The iteration converges for smooth functions if f ′(p 0 ) 6 = 0 and |p − p 0 | is small enough.

Practice Problem: Consider the equation x = x^2 + 5. Write down an algorithm based on Newton’s method to solve this equation.

Solution: We define f (x) = x^2 − x + 5, and we want to find x such that f (x) = 0. We have

xn+1 = xn −

f (xn) f ′(xn) = xn −

x^2 n − xn + 5 2 xn − 1

This equation can be and should be simplified further.

Practice Problem: What is the order of convergence of Newton’s method?

Solution: Newton’s method is quadratically convergent (second order of convergence), which means that

|x∗^ − xn+1| ≤ C|x∗^ − xn|^2.

Practice Problem: Suppose g(x), a smooth function, has a fixed point x∗; that is g(x∗) = x∗. Write a Taylor expansion of g(xn) around x∗. Solution:

g(xn) = g(x∗) + (xn − x∗)g′(x∗) + (xn − x∗)^2 2

g′′(ξn).

We can use the information that is given to us by the problem. A fixed point iteration is defined as xn+1 = g(xn). Also, g(x∗) = x∗. Using this, we can rewrite the equation as

xn+1 = x∗^ + (xn − x∗)g′(x∗) +

(xn − x∗)^2 2 g′′(ξn),

or

xn+1 − x∗^ = (xn − x∗)g′(x∗) + (xn − x∗)^2 2

g′′(ξn).

Quite a few observations can be made using this equation if additional information is given by a problem.

1.3 Secant Method

The Secant method is derived from Newton’s method by replacing f ′(pn− 1 ) with the following approximation:

f ′(pn− 1 ) ≈ f (pn− 2 ) − f (pn− 1 ) pn− 2 − pn− 1

Then, the Newton’s iteration can be rewritten as follows. This iteration is called the Secant method.

pn = pn− 1 − f (pn− 1 )(pn− 2 − pn− 1 ) f (pn− 2 ) − f (pn− 1 )

Practice Problem: Consider a binary number (also known as a machine number)

0 10000001010 10010011000000 · · · 00

Find the floating point decimal number it represents as well as the next largest floating point decimal number.

Solution: A decimal number (also known as a floating-point decimal number) is of the form:

(−1)s 2 c−^1023 (1 + f ).

Therefore, in order to find a decimal representation of a binary number, we need to find s, c, and f. The leftmost bit is zero, i.e. s = 0, which indicates that the number is positive. The next 11 bits, 10000001010, giving the characteristic, are equivalent to the decimal number:

c = 1 · 210 + 0 · 29 + · · · + 0 · 24 + 1 · 23 + 0 · 22 + 1 · 21 + 0 · 20 = 1024 + 8 + 2 = 1034.

The exponent part of the number is therefore 21034 −^1023 = 2^11. The final 52 bits specify that the mantissa is

f = 1 ·

Therefore, this binary number represents the decimal number

(−1)s 2 c−^1023 (1 + f ) = (−1)^0 · 21034 −^1023 ·

= 211 + 2^10 + 2^7 + 2^4 + 2^3.

It won’t be necessary to further simplify this number on the test.

The next largest machine number is

0 10000001010 10010011000000 · · · 01.

We already know that s = 0 and c = 1034 for this number. We find f :

f = 1 ·

Therefore, this binary number represents the decimal number

(−1)s 2 c−^1023 (1 + f ) = 211

= 211 + 2^10 + 2^7 + 2^4 + 2^3 +

It won’t be necessary to further simplify this number on the test. Note how these two numbers differ.

3 Interpolation

3.1 Lagrange Polynomials

We can construct a polynomial of degree at most n that passes through n + 1 points:

(x 0 , f (x 0 )), (x 1 , f (x 1 )),... , (xn, f (xn)).

Such polynomial is unique.

Linear (first order) interpolation is achieved by constructing the Lagrange polynomial P 1 of order 1, connecting the two points. We have:

P 1 (x) = L 0 (x)f (x 0 ) + L 1 (x)f (x 1 ),

where 1

L 0 (x) = x − x 1 x 0 − x 1

L 1 (x) = x − x 0 x 1 − x 0

Quadratic (second order) interpolation is achieved by constructing the Lagrange polyno- mial P 2 of order 2, connecting the three points. We have:

P 2 (x) = L 0 (x)f (x 0 ) + L 1 (x)f (x 1 ) + L 2 (x)f (x 2 ),

where

L 0 (x) = (x − x 1 )(x − x 2 ) (x 0 − x 1 )(x 0 − x 2 )

L 1 (x) = (x − x 0 )(x − x 2 ) (x 1 − x 0 )(x 1 − x 2 )

L 2 (x) =

(x − x 0 )(x − x 1 ) (x 2 − x 0 )(x 2 − x 1 )

In general, to construct a polynomial of order n, connecting n + 1 points, we have

Pn(x) = L 0 (x)f (x 0 ) + L 1 (x)f (x 1 ) +... + Ln(x)f (xn),

where

Lk(x) = (x − x 0 ) · · · (x − xk− 1 )(x − xk+1) · · · (x − xn) (xk − x 0 ) · · · (xk − xk− 1 )(xk − xk+1) · · · (xk − xn)

Lk are called the k−Lagrange basis functions.

(^1) Note that in some sources, Ln,k notation is used for functions below, where n designates the order of polynomial. To avoid confusion, I omit n-index since it is usually obvious what order of the polynomial we are considering. I write those functions as Lk.