Partial Differentiation

Numerically, partial differentiation works very similarly to the total differentiation we met in week 3. Say we have some function of three variables $f(x,y,z)$ that we would like to partially differentiate with respect to $x$. This means that all of the other variables, $y$ and $z$, are kept constant. Writing this in finite-difference form, we have $$\frac{\partial f}{\partial x} = \frac{f(x+h, y, z)-f(x,y,z)}{h}.$$ The same goes for the other variables $y$ and $z$. We can use these facts to evaluate partial derivatives of functions numerically.

Let us take for example $$f(x,y) = 4x^3 - 5 xy^2 + 3y^3.$$ The partial derivatives, found analytically, are \begin{align} \frac{\partial f}{\partial x} &= 12x^2 - 5 y^2, & \frac{\partial f}{\partial y} &= -10xy + 9 y^2. \end{align}

We'll start by plotting the analytical results.

Now, in the same way we did in week 3, we'll differentiate numerically to find the derivatives.

Now let's see how different the two really are.