HW4 2024
HW4 2024
HW 4, Due Dec-6, 16:00 PM (for q.1), Dec 14, 23:00 (for q.2 and 3)
Name_____________________________________
Rules: This is a take-home, open-book, open-notes work. If you refer to results from books (other
than the class text), research papers, or the web (other than the class web page(s)) carefully cite your
source(s). Answer with an Expression/Formula/Text, write intermediate solutions, not just a final
answer or suffer a penalty!!
Problem 1.
a) Suppose that we want to derive a method for approximating the derivative of f at a which has
the form
f (a ) c1 f (a − h) + c2 f (a + h), c1 , c2 R .
We want the method to be exact when f (x ) = 1 and f (x ) = x . Use these conditions to determine
c1 and c 2 . Find the error term.
b) Use the procedure in (a) to derive a method for approximating the second derivative of f ,
f (a ) c1 f (a − h) + c2 f (a ) + c3 f (a + h), c1 , c2 , c3 R
by requiring that the method should be exact when f (x ) = 1, x and x 2 . Find the error term.
Hint for a): Write down the error in the differentiation rule as f (a ) − c1 f (a − h) + c2 f (a + h) . Expand
each term on the right side in Taylor’s series about the point a and choose c1,c2 in a proper way.
1
Problem 2.
a) Write a program that implements the numerical differentiation method
f (a + h ) − f (a − h )
f (a ) ,
2h
and test the method on the function f (x ) = e x at a = 1 for h = 0.1; 0.01; 0.001 and so on. For each
h determine the absolute error (use double type of variables).
b) Use your program to determine the optimal value h of experimentally.
3 3 f (a )
c) Now determine the optimal value of h given by h , which minimizes the total error.
3 f (a )
Use = 7 10−17 .
d) Use the optimal value of h that you found in (c) to determine a better value for in this specific
example.
Problem 3 (extra).