Carry out a numerical experiment to compare the accu- racy ofFormulas (5) and (19) on a function f whose derivative can becomputed precisely. Take a sequence of valuesforh,suchas4−nwith0≦n≦12.
hint: For CE 4.3.4, use f(x) = sin x and x = 0.25, for example.Then the exact derivative is cos 0.25, so you can compare yourresults to it, compute errors, and study how they behave as hdecreases. You may want to format your outputs so that for each nyou print, on the same row, the values of h, approximate f 0(0.25), error of the approximation, and the theoretically estimatederror term (h 2/6 for formula (5) and h 4/30 for formula (19)—herewe are using the fact that the derivatives of sin x are at most 1in absolute value). Don’t forget to discuss your findings!
f′(x)≈ 1 [f(x+h)− f(x−h)] (5)
f′(x)≈ 1 [f(x+h)− f(x−h)] /2h − 1 /12h(f(x +2h)−2[f(x +h)− f(x−h)]− f(x −2h)) (19)