## E3. Evaluating derivatives numerically

Use Taylor's theorem to show that when $h$ is small \begin{alignat*}{3} f'(a) &= \frac{f(a + h) - f(a - h)}{2h} &&\quad \textrm{with an error } O(h^2 f'''(a)) \\ f''(a) &= \frac{f(a + h) - 2f(a) + f(a - h)}{h^2} &&\quad \text{with an error } O(h^2 f''''(a)) \end{alignat*}

Taking $f(x) = \sin x$, $a = \pi/6$, and $h = \pi/180$, find from a) and b) the approximate values of $f'(a)$ and $f''(a)$ and compare them to exact values.

These finite-difference formulae are often used to calculate derivatives numerically. How would you construct a more precise finite-difference approximation to $f'(a)$?

Spoiler

## E7. Change of variables

Spherical polar coordinates $(r, \theta, \phi)$ are defined in terms of Cartesian coordinates $(x, y, z)$ by $x = rsin\theta \cos\phi, \quad y = r\sin\theta\sin\phi, \quad z = r\cos\theta.$

a) Find $\partial x/\partial r$ treating $x$ as a function of the spherical polar coordinates, and $\partial r/\partial x$ treating $r$ as a function of the Cartesian coordinates.

b) Given that $f$ is a function of $r$ only, independent of $\theta$ and $\phi$, deduce that $\nabla^2 f = \frac{1}{r^2} \frac{\de}{\de r} \left( r^2 \frac{\de f}{\de r}\right).$

Spoiler 