Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
91 views

Midterm Review: 1 Root-Finding Methods

This document provides a summary of root-finding methods, including the bisection method and Newton's method. It also discusses computer arithmetic for representing floating-point numbers in binary. Additionally, it covers interpolation techniques, specifically Lagrange polynomials and Newton's divided differences, which can be used to construct polynomials that pass through given data points.

Uploaded by

eloihy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

Midterm Review: 1 Root-Finding Methods

This document provides a summary of root-finding methods, including the bisection method and Newton's method. It also discusses computer arithmetic for representing floating-point numbers in binary. Additionally, it covers interpolation techniques, specifically Lagrange polynomials and Newton's divided differences, which can be used to construct polynomials that pass through given data points.

Uploaded by

eloihy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Midterm Review

Igor Yanovsky (Math 151A TA)

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
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.
p=

The formula for midpoint above generates values pn . We can bound an error of each
iterate pn for the bisection method:
ba
.
2n
Note, as n , pn p.
|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 104 which contains a root of a function?
Solution: We need to find n such that:
ba
104 .
2n
We have

104 .
2n

,
104
104,

2n
2n

n log 2 log(104),

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

1.2

Newtons Method

The Newtons iteration is defined as:


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

Practice Problem: Consider the equation x = x2 + 5. Write down an algorithm based


on Newtons method to solve this equation.
Solution: We define f (x) = x2 x + 5, and we want to find x such that f (x) = 0.
We have
f (xn )
x2 xn + 5
xn+1 = xn 0
= xn n
.
f (xn )
2xn 1
This equation can be and should be simplified further.

Practice Problem: What is the order of convergence of Newtons method?


Solution: Newtons 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:
(xn x )2 00
g(xn) = g(x) + (xn x )g 0(x ) +
g (n ).
2
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 0(x) +

(xn x )2 00
g (n ),
2

or
(xn x )2 00
g (n ).
2
Quite a few observations can be made using this equation if additional information is given
by a problem.
xn+1 x = (xn x)g 0(x) +

1.3

Secant Method

The Secant method is derived from Newtons method by replacing f 0 (pn1 ) with the
following approximation:
f (pn2 ) f (pn1 )
f 0(pn1 )
.
pn2 pn1
Then, the Newtons iteration can be rewritten as follows. This iteration is called the
Secant method.
f (pn1 )(pn2 pn1 )
pn = pn1
.
f (pn2 ) f (pn1 )
2

Computer Arithmetic

Given a binary number (also known as a machine number), for example


0 10000001010
0}
|{z}
|
|
{z
} 10010011000000
{z
s

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


(1)s 2c1023(1 + f ).

(1)

Therefore, in order to find a decimal representation of a binary number, we need to find


s, c, and f and plug these into (1).
Problems 3 and 4 in Homework 3 are good applications of this idea. If you understand
how to do such problems, consider a similar problem below.

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 2c1023(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 210341023 = 211.
The final 52 bits specify that the mantissa is
 1
 4
 7
 8
1
1
1
1
f = 1
+1
+1
+1
.
2
2
2
2
Therefore, this binary number represents the decimal number
 1  4  7  8 !
1
1
1
1
(1)s 2c1023(1 + f ) = (1)0 210341023 1 +
+
+
+
2
2
2
2
 1  4   7   8 !
1
1
1
1
+
+
+
= 211 1 +
2
2
2
2
= 211 + 210 + 27 + 24 + 23.
It wont 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 :
 1
 4
 7
 8
 52
1
1
1
1
1
f = 1
+1
+1
+1
+1
.
2
2
2
2
2
Therefore, this binary number represents the decimal number
 1  4  7  8  52 !
1
1
1
1
1
s c1023
11
(1) 2
1+
(1 + f ) = 2
+
+
+
+
2
2
2
2
2
 41
1
.
= 211 + 210 + 27 + 24 + 23 +
2
It wont be necessary to further simplify this number on the test.
Note how these two numbers differ.
4

Interpolation

3.1

Lagrange Polynomials

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


(x0, f (x0)), (x1, f (x1)), . . . , (xn , f (xn)).
Such polynomial is unique.
Linear (first order) interpolation is achieved by constructing the Lagrange polynomial
P1 of order 1, connecting the two points. We have:
P1 (x) = L0 (x)f (x0) + L1 (x)f (x1),
where

L0(x) =
L1(x) =

x x1
,
x0 x 1
x x0
.
x1 x 0

Quadratic (second order) interpolation is achieved by constructing the Lagrange polynomial P2 of order 2, connecting the three points. We have:
P2 (x) = L0 (x)f (x0) + L1 (x)f (x1) + L2(x)f (x2),
where
L0(x) =
L1(x) =
L2(x) =

(x x1 )(x x2)
,
(x0 x1 )(x0 x2 )
(x x0 )(x x2)
,
(x1 x0 )(x1 x2 )
(x x0 )(x x1)
.
(x2 x0 )(x2 x1 )

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


Pn (x) = L0 (x)f (x0) + L1(x)f (x1) + . . . + Ln (x)f (xn),
where
Lk (x) =

(x x0) (x xk1 )(x xk+1 ) (x xn )


.
(xk x0 ) (xk xk1 )(xk xk+1 ) (xk xn )

Lk are called the kLagrange 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 .

3.2

Newtons Divided Differences

The polynomial of degree n, interpolating n+1 points, can be written in terms of Newtons
divided differences:
Pn (x) = f [x0 ] + f [x0, x1](x x0 ) + f [x0 , x1, x2](x x0)(x x1 )
+ . . . + f [x0, x1, . . . , xn ](x x0)(x x1 ) (x xn1 ).
The zeroth divided difference of f with respect to xi is
f [xi ] = f (xi ).
The first divided difference of f with respect to xi and xi+1 is
f [xi , xi+1] =

f [xi+1 ] f [xi]
.
xi+1 xi

The second divided difference is


f [xi , xi+1, xi+2] =

f [xi+1 , xi+2] f [xi , xi+1]


.
xi+2 xi

You might also like