Docsity

MATH 128A Homework 7: Numerical Methods for Function Approximation, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
MATH 128A
Homework #7
Due (in class) Thursday 07/22/04
Computer Assignment:
Do the exercises outline below for at least three of the following functions:
1/x, log(x), ex, tan(x), cosh(x) , sin(x), x3−23x.
Let
φh
1(x) = f(x+h)−f(x)
h, φh
2(x) = f(x+h)−f(x−h)
2h, φh
2(x) = 4f(x+h)−3f(x)−f(x+ 2h)
2h.
1)Select an appropriate point xand compute φh
i(x) for the functions fabove
with h= 1,1/2,1/4,1/8, /16,etc.
2)Compare the approximations that you have obtained with the exact value
of the derivative and plot your results for different h.
3)For φ1and φ2determine what portion of the error is due to round-off by
using the estimate for the truncation error derived in class. (it’s also in the
text)
4)For φ3determine the order of the method by performing the following
numerical experiment:
Assume that f0(x) = φh
3(x) + C∗hp. Use the result of your first run to
determine A1=φ1
3(x), A2=φ1/2
3(x), A3=φ1/23
3(x), etc.
Notice that Ai+1 −Ai=Chp(1/2p−1). Since pand Care both fixed, you
can try to estimate C(1/2p−1) by looking at Ai+1−Ai
hαfor different values of
α. If α < p, this ratio should be going to 0, as h→0. If α > p, it should be
blowing up. And only for α=pyou should be getting a constant non-zero
limit. Of course if hbecomes too small, roundoff will kick in. Knowing that
the machine ≈1/252, you should be able to gauge how small can hbecome
before you start getting nonsensical results.
Plot your results and carefully label them.
5)Try to think of a way to decrease the error if you have A1and A2computed,
i.e. how can you combine the two to get something which has a smaller error.

Partial preview of the text

Download MATH 128A Homework 7: Numerical Methods for Function Approximation and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

MATH 128A

Homework # Due (in class) Thursday 07/22/

Computer Assignment: Do the exercises outline below for at least three of the following functions: 1 /x, log(x), ex, tan(x), cosh(x) , sin(x), x^3 − 23 x.

Let

φh 1 (x) = f (x + h) − f (x) h

, φh 2 (x) = f (x + h) − f (x − h) 2 h

, φh 2 (x) = 4 f (x + h) − 3 f (x) − f (x + 2h) 2 h

1)Select an appropriate point x and compute φhi (x) for the functions f above with h = 1, 1 / 2 , 1 / 4 , 1 / 8 , / 16 , etc. 2)Compare the approximations that you have obtained with the exact value of the derivative and plot your results for different h. 3)For φ 1 and φ 2 determine what portion of the error is due to round-off by using the estimate for the truncation error derived in class. (it’s also in the text) 4)For φ 3 determine the order of the method by performing the following numerical experiment:

Assume that f ′(x) = φh 3 (x) + C ∗ hp. Use the result of your first run to

determine A 1 = φ^13 (x), A 2 = φ^13 / 2 (x), A 3 = φ^1 /^2

3 3 (x), etc. Notice that Ai+1 − Ai = Chp(1/ 2 p^ − 1). Since p and C are both fixed, you can try to estimate C(1/ 2 p^ − 1) by looking at Ai+1 hα− Aifor different values of α. If α < p, this ratio should be going to 0, as h → 0. If α > p, it should be blowing up. And only for α = p you should be getting a constant non-zero limit. Of course if h becomes too small, roundoff will kick in. Knowing that the machine  ≈ 1 / 252 , you should be able to gauge how small can h become before you start getting nonsensical results. Plot your results and carefully label them. 5)Try to think of a way to decrease the error if you have A 1 and A 2 computed, i.e. how can you combine the two to get something which has a smaller error.