Chapter 4: Problem 3
Suppose we have a function \(f(x)\) and we want to calculate its derivative at a point \(x\). We can do that with pencil and paper if we know the mathematical form of the function, or we can do it on the computer by making use of the definition of the derivative: $$ \frac{\mathrm{d} f}{\mathrm{~d} x}=\lim _{\delta \rightarrow 0} \frac{f(x+\delta)-f(x)}{\delta} $$ On the computer we can't actually take the limit as \(\delta\) goes to zero, but we can get a reasonable approximation just by making \(\delta\) small. a) Write a program that defines a function \(f(x)\) returning the value \(x(x-1)\), then calculates the derivative of the function at the point \(x=1\) using the formula above with \(\delta=10^{-2}\). Calculate the true value of the same derivative analytically and compare with the answer your program gives. The two will not agree perfectly. Why not? b) Repeat the calculation for \(\delta=10^{-4}, 10^{-6}, 10^{-8}, 10^{-10}, 10^{-12}\), and \(10^{-14}\). You should see that the accuracy of the calculation initially gets better as \(\delta\) gets smaller, but then gets worse again. Why is this? We will look at numerical derivatives in more detail in Section 5.10, where we will study techniques for dealing with these issues and maximizing the accuracy of our calculations.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.