MATH 373: Homework 2 ”Rootfinding” Fall 2013

advertisement
Assigned: Tuesday Sept. 10, 2013
Due Date: Thursday Sept. 26, 2013
MATH 373: Homework 2
”Rootfinding”
Fall 2013
NOTE: For each homework assignment observe the following guidelines:
• Include a cover page.
• Always clearly label all plots (title, x-label, y-label, and legend).
• Use the subplot command from MATLAB when comparing 2 or more plots to make
comparisons easier and to save paper.
1. Consider the function f (x) = x3 − 2.
(a) Show that f (x) has a root α in the interval [1, 2].
(b) Compute an approximation to the root by taking 4 steps of the bisection
method (BY HAND).
(c) Repeat, using Newton’s method. Take x0 = 1.5 for the starting value.
For each method,
Column 1:
Column 2:
Column 3:
Column 4:
present the results in the form of a table:
n (step)
xn (approximation)
f (xn ) (residual)
|α − xn | (error)
2. SOURCE CODE:
Write separate MATLAB functions for the bisection method, the method of
false position, Newton’s method, and the secant method. These functions
should be written so that they can be called in MATLAB by typing:
• [x,NumIters] = Bisection(@f,a,b,TOL,MaxIters)
• [x,NumIters] = FalsePos(@f,a,b,TOL,MaxIters)
• [x,NumIters] = Newton(@f,@df,x0,TOL,MaxIters)
• [x,NumIters] = Secant(@f,x0,x1,TOL,MaxIters)
Here f (x) is the function whose root we are trying to approximate and df (x) is its
derivative. Include your source code with the rest of your assignment.
1
Assigned: Tuesday Sept. 10, 2013
Due Date: Thursday Sept. 26, 2013
3. DISCUSSION QUESTION:
Each of the functions
f1 (x) = sin(x) − x − 1
f2 (x) = x(1 − cos(x))
f3 (x) = ex − x2 + 3x − 2
has a root in the interval x ∈ [−2, 1]. Use all four of the above rootfinding methods
to approximate to within an absolute tolerance of 10−6 the root of each function.
Limit the number of iterations to 500. For Newton’s method use the starting value
x0 = 1; for the secant method use x0 = 1 and x1 = 0.9. Summarize the results of
your analyses in table form:
Bisection Method
Function
Num. Iters.
Approx. Root
False Position
Num. Iters.
Approx. Root
f1 (x)
f2 (x)
f3 (x)
Newton’s Method
Function
Num. Iters.
Approx. Root
Secant Method
Num. Iters.
Approx. Root
f1 (x)
f2 (x)
f3 (x)
(a) Why did the bisection method require approximately the same number of iterations to converge to the approximate root for all three test problems?
(b) Newton’s method should have experienced difficulty approximating the root
of one of the test functions. Identify which function presented a problem and
explain why the difficulty occurred.
(c) Above you used the bisection method to find the root of the function f1 (x) =
sin(x) − x − 1. Consider the function g1 (x) = (sin(x) − x − 1)2 . Clearly f1 (x)
and g1 (x) have the same root in x ∈ [−2, 1]. Could the bisection method be
used to numerically approximate the root of g1 (x)? Why or why not?
2
Assigned: Tuesday Sept. 10, 2013
Due Date: Thursday Sept. 26, 2013
4. The function f (x) = cos(x) has a root at x = π/2. Using the theory we developed
for fixed point iterations, find the largest interval around x = π/2 in which we can
choose an initial guess for Newton’s method and still be guaranteed to converge
to π/2.
5. Show that the iteration scheme
αn+1 = g(αn ) =
αn2 − aαn + a2 + 5a
,
αn + 5
n≥0
converges to the fixed point a quadratically (i.e., order of convergence is 2) for all
a 6= −5.
6. A root α is said to be of multiplicity m if
f (α) = f 0 (α) = . . . = f (m−1) (α) = 0,
but f (m) (α) 6= 0. If f (x) has a root of multiplicity m at x = α, we can write
f (x) = (x − α)m h(x),
where h(α) 6= 0. Recall that Newton’s method is a fixed point iteration where
xn+1 = g(xn ) = xn −
f (xn )
.
f 0 (xn )
Also recall that a sequence {xn }∞
n=0 converges to α if
|xn+1 − α|
= M,
n→∞ |xn − α|p
lim
where p > 0 is the order of convergence and M > 0 is the asymptotic error constant.
If p = 1 then 0 < M < 1 in order for the sequence to converge linearly.
(a) Show that if m = 1 (α is a simple root) then Newton’s method converges
quadratically (p = 2) to α.
(b) Show that for all integers m > 1 Newton’s method converges only linearly
(p = 1) to α. (NOTE: must show that 0 < M < 1.)
(c) Consider the following modified Newton’s method:
xn+1 = g(xn ) = xn − m
f (xn )
.
f 0 (xn )
Show that this modified Newton’s method converges quadratically (p = 2) to
α for all positive integers m.
3
Assigned: Tuesday Sept. 10, 2013
Due Date: Thursday Sept. 26, 2013
2
(d) The function f (x) = e−x · (x − 10)5 has a root of multiplicity m = 5 at x = 10.
Apply both Newton’s method and the modified Newton’s method to this
problem using an initial guess of x0 = 3 and a tolerance of 10−6 . On a single
semilogy graph, plot for both methods the absolute error |α − xn | (y-axis) vs.
iteration number n (x-axis).
7. APPLICATION PROBLEM:
The van der Waal equation
P+
a (V − b) = nRT
V2
generalizes the ideal gas law P V = nRT . In each equation, P represents the pressure
(atm), V represents the volume (liters), n is the number of moles of gas, and T
represents the temperature (K). R is the universal gas constant and has the value
R = 0.08205
liters · atm
.
mole · K
Determine the volume of 1 mole of isobutane at a temperature of T = 313K and
a pressure of P = 2 atm, given that, for isobutane, a = 12.87 atm · liters2 and
b = 0.1142 liters. Compare this to the value predicted from the ideal gas law. You
may use any one of your methods (make clear in your writeup which one you are
using, what initial guesses or intervals you are using, etc...).
8. APPLICATION PROBLEM:
According to Archimedes’ law, when a solid of density σ is placed in a liquid of
density ρ, it will sink to a depth h that displaces an amount of liquid whose weight
equals the weight of the solid. For a sphere of radius r, Archimedes law translates
to
1
4
π 3rh2 − h3 ρ = πr3 σ.
3
3
Given r = 5, ρ = 1, and σ = 0.6, determine h. You may use any one of your methods
(make clear in your writeup which one you are using, what initial guesses or intervals
you are using, etc...).
4
Download