Partial derivatives fx\frac{\partial \operatorname{f}}{\partial x}, fy\frac{\partial \operatorname{f}}{\partial y}, ...

This is very similar to the normal derivative. Often, functions do not only depend on one variable, but on many, think "what is the temperature at a location (x,y) on the map". A partial derivative tells you how much a function value at a position changes if you change one of the variables a tiny bit.

The squiggly \partial symbols can be read a few ways. Sometimes, people just say "d f d x" or "partial of f with respect to x" or "del f [by] del x". There are a few ways to say it...

Here we will show the definitions for the 2D case.

f(x,y)x=limh0f(x+h,y)f(x,y)hf(x,y)y=limh0f(x,y+h)f(x,y)h\begin{align*} \frac{\partial \operatorname{f}(x,y)}{\partial x} &= \lim\limits_{h \rightarrow 0} \frac{\operatorname{f}(x + h, y) - \operatorname{f}(x,y)}{h} \\ \frac{\partial \operatorname{f}(x,y)}{\partial y} &= \lim\limits_{h \rightarrow 0} \frac{\operatorname{f}(x, y + h) - \operatorname{f}(x,y)}{h} \end{align*}

For the general case, it is easier to number the coordinates, like x1,,xnx_1, \dots, x_n. Then we can write:

f(x1,,xi,,xn)xi=limh0f(x1,,xi+h,,xn)f(x1,,xi,,xn)h \frac{\partial \operatorname{f}(x_1, \dots, x_i, \dots, x_n )}{\partial x_i} = \lim\limits_{h \rightarrow 0} \frac{\operatorname{f}(x_1, \dots, x_i + h, \dots, x_n ) - \operatorname{f}(x_1, \dots, x_i, \dots, x_n )}{h} \\

The only difference (in this simple case) to the 1D derivative is, that a function depends on multiple values and you need to change just one of them. Depending on how you represent these, the implementation changes slightly. The easiest would be to represent the variables as a vector. Then you can specify the variable that you want to differentiate with respect of by its index.

Code: