2024-11-18

What are Partial Derivatives?

You may know that the derivative of a function is equal to the rate of change of that function at any given point, or, graphically, the slope of the function at any given point. Graphing a derivative of a function alongside it will show high positive numbers when a function is rapidly increasing, and negative numbers when it is decreasing. However, beginner function derivatives only take into account two axes, one for input and one for output. What happens in higher dimensions?

In a 3d space, terms like ‘increasing’ and ‘decreasing’ become muddled, as there are now multiple directions in which a function can increase or decrease. For example, one point on a 3d graph could increase in regards to the z value when moving up on the y-axis, yet decrease moving up on the x-axis.

Partial Derivatives, cont.

This is where partial derivatives come into play. If we want to know how a function behaves in regards to the x or y axes only, we can compute a partial derivative to map the rate of change in that specific direction to the graph of the original function.

Consider the following function:

\[ f(x,y) = x^2y+2x-3y+xy \]

Graphing the 3D Equation

We can use plotly to graph this equation, which takes two input variables and returns a third.

x = seq(-10,10,0.1)
y = seq(-10,10,0.1)
X = matrix(rep(x,length(y)),nrow=length(y), byrow = TRUE)
Y = matrix(rep(y,length(x)),ncol=length(x), byrow = FALSE)
Z = (X*X*Y) + (2*X) - (3*Y) + (X*Y)
plot_ly(x = X, y = Y, z = Z) %>% add_surface()

Graphing the 3D Equation, cont.

Taking the Partial Derivative

In order to take a partial derivative with respect to one variable (in this case x), that is to say, find the rate of change of the entire function in regards to x, we simply need to integrate the entire function treating y as if it were a constant. Therefore, we take

\[ f_{x}(x,y) = \displaystyle \frac{\partial f}{\partial x}(x^2y+2x-3y+xy) \] \[ y\frac{dz}{dx}x^2+\frac{dz}{dx}2x-3y\frac{dz}{dx}0+y\frac{dz}{dx}x \]

Solving, we obtain

\[ f_{x}(x,y) = 2xy+2+y \]

Let’s compare this to the original graph.

Graphing the 3D Partial Derivative

2D Slice of a Partial Derivative

If we take a 2d slice along the x-axis by setting y equal to a constant in both functions, we should be able to obtain a 2d function and its derivative. This is because the derivative is in regards to only the x-axis, so reducing the dimension will result in the actual derivative.

Setting the y value of the equations equal to 2, we obtain

\[ f(x) = 2x^2+4x-6 \]

and

\[ f'(x) = 4x+4 \]

we obtain…

2D Slice of a Partial Derivative, cont.

2D Slice of a Partial Derivative, cont.

The graph shows that the slice of the function indeed has the correct derivative, with the point where the curve is stagnant corresponding tot he point where the derivative crosses the x-axis. We can do the same equations for the partial of y.

\[ f_{y}(x,y) = \displaystyle \frac{\partial f}{\partial y}(x^2y+2x-3y+xy) \]

\[ f_{y}(x,y) = x^2-3+x \]

Setting x = 2, we obtain

\[ f(y) = 3y + 4 \]

\[ f'(y) = 3 \]

2D Slice of a Partial Derivative, cont.