The complex-step formula can be worked by hand for a polynomial

PHYSICS · Multi-part · Fermi University Physics · Mathematical Methods for Physics · Numerical and computational mathematics · Numerical and computational mathematics

Error, Chance and the Machine, Ch Approximating a function: interpolation and differentiation

Problem

The complex-step formula f′(x)≈Im f(x+ih)/hf'(x)\approx \mathrm{Im}\,f(x+ih)/h can be worked by hand for a polynomial. Take f(x)=x3f(x)=x^3, the point x=1x=1 and a real step hh. ((a)) Expand (1+ih)3(1+ih)^3 and find Im f(1+ih)/h\mathrm{Im}\,f(1+ih)/h exactly. Evaluate it for h=0.1h=0.1. ((b)) Find the error of the formula (formula minus exact f′(1)f'(1)) and show that it equals −h2f′′′(1)/6-h^2f'''(1)/6. Evaluate it for h=0.1h=0.1. ((c)) Find the error of the central difference [f(1+h)−f(1−h)]/2h[f(1+h)-f(1-h)]/2h in the same way, and compare it with your answer to (b) at h=0.1h=0.1. ((d)) At h=10−8h=10^{-8} both truncation errors are of order 10−1610^{-16}. Explain why only the complex step delivers a derivative that accurate in binary64.

Browse the problem library