Homework Questions The Bisection Method: Overview

advertisement
Homework Questions
The Bisection Method: Overview
The idea: Use the Intermediate Value Theorem to find a solution to f (x) = 0.
The following problems will also be posted on the website.
The method: Let f be a continuous function and E the desired error bound:
I
1. Why does the bisection method work?
2. Describe (in words, NOT math), the idea behind Newton’s method.
3. How might you solve the equation 7x3 + 2x − 5 = 0 with the fixed-point
algorithm?
I
4. What advantage does the bisection method have over the other two
methods?
I
5. In what ways are Newton’s method and the fixed-point algorithm superior
to the bisection method?
6. If you only had a scientific calculator at your disposal (along with pencil
and paper), which method would you prefer to use to solve an equation
without an algebraic solution? Explain.
Problems from the text: §3.7 # 3, 6, 12, 26
*You will need a calculator or some other device to complete these problems.
Make use of the step-by-step algorithms outlined in the text as well.
§3.7 – Solving Equations Numerically
Isolate one root of the equation (if there
are multiple) in an interval [a1 , b1 ] so that
f (a1 ) · f (b1 ) < 0 and f (b1 ).
Find the midpoint between a1 and b1 ,
a1 + b1
.
m1 =
2
If f (m1 ) = 0, we’re done!
I
If we’re not so lucky, calculate
b1 − a1
. This is half the length of
h1 =
2
the interval (i.e. the max distance we
could be from our target).
I
Check the sign of f (m1 ): If
f (a1 ) · f (m1 ) < 0, set a2 = a1 and
b2 = m1 . If not, set a2 = m1 and
b2 = b1 .
I
Use this as the new interval, and repeat
the process until you achieve the desired
accuracy, when hn < E.
The Bisection Method: Results
Since we wanted to solve f (x) = 2x2 − sin(x) exactly for 8 decimal places, our error
E = 0.00000001 = 10−8 .
Bisection: x = 0.48094596
Why: Some equations cannot be solved algebraically, so we need some other
way of identifying such solutions.
0.55
0.50
the bisection method
I
Newton’s method
I
the fixed-point algorithm
m
1e−04
0.40
the equation f (x) = 2x2 − sin(x) accurate to 8 decimal places:
I
1e−02
0.45
How: We’ll review 3 common methods for approximating the positive root to
error
1e−06
0.35
1e−08
1
27
iteration
1
iteration
27
1.0
Some questions:
2x2 − sin(x)
1. How do we determine accuracy?
2. Is any method better than the others?
0.5
0.0
a
a aaa
bb b
0.2 0.4 0.6 0.8
b
1
−0.5
? The bisection method will always work...but it takes a lot of iterations to get a high
level of accuracy.
What We Want
Newton’s Method: Overview
Common practice: Use a graph (via computer or calculus!) of the function
to identify an interval containing the solution: 0 < x ≤ 1
The idea: Use tangent lines to obtain successively better approximations to the
solution.
1.0
The method: Let f be a continuous function and E the desired error bound:
I
2x2 − sin(x)
0.5
I
0.0
0.2
0.4
0.6
0.8
y − f (x1 ) = f 0 (x1 )(x − x1 ) ⇒ y = f 0 (x) · x + f (x1 ) − f 0 (x1 ) · x1 .
Calculate where this tangent line hits the x-axis by solving the above for x
when y = 0. Name the result x2 :
x2 = x1 −
1
I
−0.5
Start with initial guess x1 . The equation of the tangent line at x1 is
f (x1 )
f (xn )
⇒ xn+1 = xn − 0
f 0 (x1 )
f (xn )
Repeat for increasing n until |xn+1 − xn | < E.
Newton’s Method: Results
The Fixed-Point Algorithm: Overview
Newton’s: x = 0.48094596
error
0.9
1e−02
0.8
The idea: Find the solution to an equation of the form x = g(x), where x is a
fixed point of g. This amounts to determining where the graphs of y = x and
y = g(x) meet.
1e−04
0.7
1e−06
0.6
1e−08
0.5
1e−10
The method: Let g be a continuous function and E the desired error bound:
1
7
iteration
7
iteration
1.0
2x2 − sin(x)
0.8
0.6
I
Start with initial guess x1 .
I
Calculate xn+1 = g(xn ) for increasing n until |xn+1 − xn | < E.
Note: To solve f (x) = 2x2 − sin(x) = 0, we can use the fixed point algorithm
0.4
to solve x = g(x) = x − f (x) or x = x − (2x2 − sin(x)) .
0.2
0.0
−0.2
0.2
0.4
0.6
0.8
1
? Newton’s method converges to the answer much faster than the bisection method.
It’s also simpler to implement.
Newton’s Method: Results
The Fixed-Point Algorithm: Results
Newton’s: x = 0.48094596
Fixed−point: x = 0.48094596
error
1e−01
error
1e−04
0.45
0.40
0.35
1e−07
0.30
0.4
1e−10
0.25
1e−06
0.3
1e−13
0.20
1e−08
0.7
0.6
0.5
1
8
iteration
1.0
2x2 − sin(x)
1e−04
1
8
iteration
1e−02
9
iteration
iteration
9
1.0
0.8
0.8
0.6
0.6
g(x) = x − f(x)
f(x) = 2x2 − sin(x) 0.4
0.4
0.2
0.2
0.0
−0.2
0.2
0.4
0.6
0.8
1
0.0
−0.2
? Choosing a different initial guess can often result in the correct answer...but not
always.
Newton’s Method: Results
Newton’s: x = 0
error
0.2
0.1
0.0
−0.1
−0.2
−0.3
−0.4
1e−02
1e−05
1e−08
1e−11
1
8
iteration
iteration
8
1
0.5
−0.5
0.0
0.5
1.0
? A bad initial guess can cause Newton’s method to fail.
? Based on the formula xn+1 = xn −
will result in failure too.
f (xn )
,
f 0 (xn )
any guess resulting in a stationary point
0.2
0.6
1
? The fixed-point algorithm is as fast as Newton’s method in terms of
convergence. It will also work for most, but not necessarily all initial guesses.
Download