Partial Differentiation

Partial Differentiation
L. M. Kalnins, January 2010
Just as ordinary derivatives enable us to study the rate of change of a function of one variable, partial
derivatives enable us to study the rates of change of a function of multiple variables. If f is a function
of x and y, it will have two independent rates of change, one describing how f changes with a change
in x with y held constant and onedescribing
howf changes with change in y with x held constant.
∂f
These are the partial derivatives ∂x
and ∂f
. Even though y is held constant, the value of
∂y
y
∂f
∂x y
x
may depend on that constant value. For example, whether food is spoils or not depends on
both temperature and time, but a small increase in time will increasing the odds of spoiling much
more if the temperature
is high
than if it is low; even though the temperature itself is constant, it will
.
affect the value of ∂spoiling
∂time
temp
Notation: ‘d’, ‘∂’, and what it means when you have ‘half a derivative’
With ordinary derivatives, we said that df
dx was the rate of change of f with respect to x. The same is
∂f
true with partial derivatives: ∂x is still the rate of change of f with respect to x. The ‘∂’ symbol
y
is used to indicate that f does not depend only on x, i.e. there will be other rates of change for f with
respect to the other variables. The subscript y tells us that y is held constant, meaning that we don’t
have f (x); we have f (x, y). The subscripts should be used whenever it might be ambiguous which
other variables are involved. Likewise, f 0 is seldom used with partial derivatives because it is not clear
what variable you are differentiating by. (There are types of notation to get around this, but we don’t
use them in this course.)
∂x
So if you write dx
dt you are implying that x is a function only of t. If you write ∂t , you are implying
that x is a function of several variables, and you are considering how x changes when only one of
them, t changes.
When working with derivatives, we often encounter what looks like ‘half a derivative’, just dx on its
own. dx is a tiny change in x (rigourously, an infinitesimal change). So, broken down, the derivative
dx
dt is a tiny change in x divided by a tiny change in t. On a graph of x as a function of t, dt would be
the movement along the t axis, dx the movement along the x axis, and dx
dt the slope of the line.
Taking a Partial Derviative
Partial derivatives follow the same rules as ordinary derivatives - the product rule, the chain rule, the
quotient rule, etc. The major difference is the need to pay attention to which variables are being held
constant, and thus must be treated like any other constant, for this differentiation.
Example 1: Calculate
Answer:
∂f
∂x y
∂f
∂x y
if f (x, y) = x2 y − sin(2x) cos(y 3 + 4)
= 2xy − 2 cos(2x) cos(y 3 + 4)
Note the similarity to f (x) = ax2 − b sin(2x),
df
dx
= 2ax − 2b cos(2x)
As with ordinary derivatives, it is not necessary to have the equation in a form where the dependent
function is alone on the left hand side while the right hand side contains only the independent variables.
1
You can differentiate both sides of the equation, so long as you are careful to remember what is an
independent variable and should be treated as a constant and what is a dependent variable, where
you will need to use the chain rule.
Example 2: Consider two possible sets of variables for a function, (x, y) and (u, v). The two sets of
variables are related by x2 sin(u) + y 2 cos(v) = 2uvy. Differentiate with respect to y.
Answer: Consider dependent versus independent variables with respect to y, the variable
by which we are differentiating. x is independent; u and v are dependent. Thus we get:
x2 cos(u)
∂u
∂v
∂u
∂v
+ 2y cos(v) − y 2 sin(v)
= 2 vy + 2u y + 2uv
∂y
∂y
∂y
∂y
N.B. Knowing which variable is being held constant
is particularly important if you want to use the
du
1
∂u
1
. However, looking at the variables in this
reciprocal of a derivative. Just as dx = dx , ∂y = ∂y
( ∂u ) x
x
du
1
example, if we differentiate by u, we should be holding v constant, and ∂u
∂y x 6= ( ∂y ) .
∂u v
Choosing Dependent and Independent Variables
In many cases, the problem is constructed such that the choice of variables is fixed, though you may
have to determine what is being said or implied about the dependence or independence of each variable.
In other cases, the choice may be more open — you may be able to choose to describe an object’s
motion in Cartesian or polar coordinates, or to pick which two variables to treat as independent in a
thermodynamics question. If you are choosing variables, consider 1) if the end goal requires (or is at
least aided by) a particular choice of variables — if you need to find a partial derivative with respect
to P with T held constant, you’re going to need to treat P and T as independent at some point 2)
what makes the equations easy to set up — an object moving in a circle has a simpler description in
polar coordinates than in Cartesian ones.
Simultaneous Equations in Partial Derivatives
Again consider two possible sets of variables (x, y) and (u, v). Say you are asked to find the partial
derivative ∂u
∂x . If you can write an expression of the form u = f (x, y), i.e. u as a function of the variable
of differentiation (x here) and variables independent of it (y here), calculating the partial derivative
is relatively straightforward, analogous to example 1.
Often, though, it is not easy (or even impossible) to write u = f (x, y). It may be difficult to isolate u on
the left-hand side, or it may be difficult to eliminate v. In this case, you will have to take a derivative
∂v
analogous to example 2. However, you can still find expressions for ∂u
∂x and ∂x . In order to relate (x, y)
to (u, v), you will need two equations (two unknowns, hence two equations). By differentiating both
∂v
equations with respect to x, you will create two equations in ∂u
∂x and ∂x . You now have simultaneous
equation in partial derivatives. As you are just rearranging equations, the partial derivatives behave
just like any other algebraic quantity, and the equations can be solved with any of the usual techniques
for simultaneous equations.
Example 3: Find
∂u
∂x
and
∂v
∂x
for (x, y) and (u, v) related by
ux = vy
and vx2 + u2 y = 3
2
Answer:
∂u
∂v
=y
∂x
∂x
∂u
2 ∂v
+ 2uy
=0
2vx + x
∂x
∂x
∂v
u x ∂u
= +
∂x
y
y ∂x
u
∂u
∂u
x
2vx + x2
+ 2uy
+
=0
y
y ∂x
∂x
u+x
⇒
⇒
ux
2x v +
y
⇒
⇒
x3 + 2uy 2
+
x3
+ 2uy
y
!
∂u
=0
∂x
∂u
= −2x (vy + ux)
∂x
∂u
−2x (vy + ux)
=
∂x
x3 + 2uy 2
∂v
u x −2x(vy + ux)
= + ·
∂x
y
y
x3 + 2uy 2
⇒
⇒
The Total Derivative
When you have (or need) an equation involving multiple ‘d’s, dS, dT, dP, etc., it’s important to
remember what those quantities mean. You’re looking for an equation that describes, for example,
how the change in f depends on the change x and the change in y. If f = xy, then we might notice that
if you change x by a little bit, the effect of that change on f will be magnified by whatever the current
value of y is, because f = xy, and likewise for a small change in y, giving us df = ydx + xdy.
More formally, what you are looking for in this case is the total derivative of f , the expression that
describes how f changes as a function of the change in each of the variables on which f depends. For
each variable, this will be equal to the change in that variable multiplied by the rate of change of f
with respect to that variable. Thus,
df =
∂f
∂x
dx +
y
∂f
∂y
dy
for any
f (x, y)
x
Note that this gives the same answer as we got above if f = xy. The total derivative expression can
be expanded for as many variables as necessary, for example,
df =
∂f
∂x
dx +
y,z
∂f
∂y
dy +
x,z
∂f
∂z
dz
for any
f (x, y, z)
x,y
Combining Differentials using Geometry
In cases where the variables are spatial coordinates, you can sometimes deduce similar relationships
using geometry, for example when determining arc length. The differential arc length, dl, can be
treated as a straight line. We thus have (dl)2 = (dx)2 + (dy)2 , where dx and dy are the differential
3
lengths
in x and y associated with a segment of arc. This can then be rearranged to give dl =
r
2
dy
1 + dx
dx. Make sure you understand this rearrangement. What is the equivalent expression for
an integral in terms of y rather than x?
Exact and Inexact Differentials
An expression M (x, y)dx + N (x, y)dy is exact if there exists an f such that M =
∂f
∂x y
and N =
∂f
∂y x ,
e.g. if there exists a function such that this expression is its total derivative. As we will see at
the end of Hilary Term, this becomes important when working with differential equations, when an
exact differential can be solved directly whilst an inexact one requires an integrating factor.
∂2f
∂2f
∂x∂y = ∂y∂x
∂2f
∂2f
∂x∂y = ∂y∂x .
In order to test for exactness, we use the fact that
for any analytic function f .1 Therefore,
(N.B. Derivatives are read right to left,
an expression M (x, y)dx + N (x, y)dy is exact iff
e.g. the left-hand side describes differentiating first with respect to y and second with respect to
x.)
The Chain Rule in Multiple Variables
Just as with ordinary derivatives, the chain rule can be used to express a derivative in terms of a
different set of variables. If F can be expressed in terms of either (x, y) or (u, v), then we can relate
the partial derivatives of F in one set of variables to partial derivatives in the other set of variables as
follows (Variables held constant shown only for the first equation. For conciseness, these are usually
omitted if doing so doesn’t introduce ambiguity.):
∂F
∂x
=
y
∂F
∂u
v
∂u
∂x
+
y
∂F
∂y
=
∂F ∂u ∂F ∂v
+
∂u ∂y
∂v ∂y
∂F
∂u
=
∂F ∂x ∂F ∂y
+
∂x ∂u
∂y ∂u
∂F
∂v
=
∂F ∂x ∂F ∂y
+
∂x ∂v
∂y ∂v
∂F
∂v
u
∂v
∂x
y
Essentially, the first equation says, if I change x a little bit, that will change both u and v. I can find
how fast F changes when I change x by multiplying how fast F changes when u changes by how fast
u changes when I change x plus the same for v.
1
All the nice, normal functions you are likely to think of are analytic. Examples of functions whose mixed derivatives
may not be equal include 1) functions whose derivatives are discontinous (|x| has a discontinuous derivative, for example,
though since it has only one variable, mixed partial derivatives aren’t relevant) and 2) functions which are path-dependent,
i.e. the value of the function depends not only where you are, but on how you got there. A somewhat trivial example
of a path-dependent function would be the orientation of a ball rolling on a tabletop. If you put a dot on the ball and
started at the ‘origin’ of the table with the dot directly on the table, the position of the dot by the time you got to some
second point on the table would depend on the path you took as you rolled the ball, i.e. it’s a path dependent function.
4
Example 4: The position function P has been expressed in terms of Cartesian coordinates x and y,
but you need the partial derivatives with respect to polar coordinates r and θ.
∂P
∂r
=
∂P ∂x ∂P ∂y
+
∂x ∂r
∂y ∂r
∂P
∂θ
=
∂P ∂x ∂P ∂y
+
∂x ∂θ
∂y ∂θ
and x = r cos θ,
y = r sin θ
by the chain rule
so
∂P
∂r
=
∂P
∂P
· (cos θ) +
· (sin θ)
∂x
∂y
∂P
∂θ
=
∂P
∂P
· (−r sin θ) +
· (r cos θ)
∂x
∂y
Higher Order Derivatives of Arbitrary Functions
Frequently you will be asked to find not just first order partial derivatives such as ∂f
∂x but also higher
∂2f
∂2f
order derivatives such as ∂x2 or ∂x∂y . If you are given a specific function, e.g. f = x2 + xy + y 2 , this is
straightforward: to find
∂2f
∂x∂y ,
∂2f
∂x2
take
∂f
∂x
= 2x + y and differentiate again by x to get
∂2f
∂x2
= 2. Similarly,
to get
differentiate f first by y and then by x. If you told to find a partial derivative of f , where
f can be any arbitrary function, the process is still the same, but it is important to remember that
differentiation is an operator — it performs some action on the expression in its brackets. This means
∂
you must be careful to differentiate the quantity in the brackets, not try to ‘multiply out’ using ∂x
as
one of the terms.
Example 5: Consider a function f such that
∂f
∂x
= x2 ∂f
∂y +2x sin(x). Find an expression for
Answer: Differentiate the given expression for
as necessary.
∂2f
∂x2
using the product rule and chain rule
=
∂
∂x
=
∂
∂f
x2
+ 2x sin(x)
∂x
∂y
∂f
∂x
∂f
∂x ,
= 2x
∂2f
.
∂x2
∂f
∂2f
+ x2
+ 2 sin(x) + 2x cos(x)
∂y
∂x∂y
Choosing a Technique for a Problem
There are several cues in the problem that can help you determine which technique to use.
• Does it tell you? Please don’t ignore instructions telling you to use, say, a total derivative.
5
• Do you need to find partial derivatives? Your choices here are essentially either to rearrange
equations and then differentiate or differentiate and then rearrange equations. If you can easily
isolate the variable you want to differentiate, the first option is usually easier. Otherwise,
differentiate the equations as they are, and use simultaneous equations in partial derivatives.
• Consider your variables. Do you have two completely independent sets of variables? If so,
the chain rule is probably going to be involved in relating derivatives in one set to derivatives
in the other set. Do you have a set of variables that are all ‘connected’, e.g. you can choose any
two or three to be independent, but then all the others are dependent? Total derivatives are
often useful here, although the chain rule can be used so long as you are very careful to write
down which variables are being held constant for each and every partial derivative.
• Consider the form of what’s being asked. Especially useful in questions that ask you to
show something. Can you recognise the outline of the chain rule or a total derivative in the
expression you are trying to derive?
• Try differentiating and see what happens. If you cannot see what technique to use, try
differentiating by the required variable, and then see what problems you encounter. If you
∂v
end up with ∂x
in your expression when you only wanted ∂u
∂x , then you now have a hint that
simultaneous equations in partial derivatives are required. If you encounter problems with your
function being in terms of variables that depend on the variable by which you’re differentiating,
then you probably need the chain rule (could potentially also be done with total derivatives).
Example 6: Consider
a function
F (x, y)where
y can
be
expressed as a function of x and z. Find
∂F
∂F
∂F
∂F
expressions relating ∂x
to ∂x
and ∂z
to ∂y .
z
y
x
x
Answer: This can be solved either with total derivatives, or more concisely but with more
care required, with the chain rule. Total derivatives:
dF =
dF =
dy =
∂F
∂x
∂F
∂x
∂y
∂x
"
⇒
dF =
⇒
∂F
∂x
dx +
y
dx +
z
dx +
z
∂F
∂x
=
z
+
y
∂F
∂x
∂F
∂y
∂F
∂z
∂y
∂z
∂F
∂y
+
y
dy
x
dz
x
dz
x
x
∂F
∂y
∂y
∂x
#
x
dx +
z
∂y
∂x
∂F
∂y
and
z
x
∂F
∂z
∂y
∂z
dz
x
=
x
∂F
∂y
x
∂y
∂z
x
Chain rule: Remind yourself of the sets of variables you are using, (x, y) and (x, z). Note
down which variables are being held constant on each partial derivative.
∂F
∂x
∂F
∂z
=
z
=
x
∂F
∂x
∂F
∂x
y
y
∂x
∂x
∂x
∂z
∂F
∂y
∂F
∂y
+
z
+
x
6
x
x
∂y
∂x
∂y
∂z
z
x
However
⇒
∂x
∂x
∂F
∂x
= 1 and
z
=
z
∂F
∂x
∂x
∂z
+
y
=0
x
∂F
∂y
x
7
∂y
∂x
and
z
∂F
∂z
=
x
∂F
∂y
x
∂y
∂z
x