Partial Derivative vs Total Derivative: Function depending Implicitly and Explicitly on Variable

1.9k Views Asked by At

I have a quick question that I hope someone can shed some light on for me. Its to do with partial derivatives and total derivatives (In this case I was working on Lagrangian Formalism but its really a general question). Im a theoretical physics student so although I do study a good deal of mathematics, we dont really go into the same level of detail that say a mathematician would (Lets just say some serious abuse of notation does occur more than one would like)

So lets assume I have some function $L = L(q_i(t),q_i'(t))$.

If I take the partial derivative of $L(q_i(t),q_i'(t))$ then, through the chain rule, I get

$$\frac {\partial L}{\partial t} = \frac {\partial L}{\partial q_i} \frac {\partial q_i}{\partial t} + \frac {\partial L}{\partial q_i'} \frac {\partial q_i'}{\partial t}.$$

Sound so far.

Lets assume now that the function $L \to L(t,q_i(t),q_i'(t))$ (i.e an explicit time dependence is now introduced in addition to the implicit time dependence.) If I now take the total derivative of said function, then I get

$$\frac {dL}{dt} = \frac{\partial L}{\partial t} + \frac {\partial L}{\partial q_i} \frac {\partial q_i}{\partial t} + \frac {\partial L}{\partial q_i'} \frac {\partial q_i'}{\partial t}.$$

But how would I now compute $\frac {\partial L}{\partial t}$? If I just apply the same logic and the chain rule, I would say that

$$\frac {\partial L}{\partial t} = \frac{\partial L}{\partial t} + \frac {\partial L}{\partial q_i} \frac {\partial q_i}{\partial t} + \frac {\partial L}{\partial q_i'} \frac {\partial q_i'}{\partial t}.$$

However, here comes my issue with the whole thing. If the above is true, then that would mean that

$$\frac {dL}{dt} = \frac {\partial L}{\partial t}$$

and also that

$$\frac {\partial L}{\partial q_i} \frac {\partial q_i}{\partial t} + \frac {\partial L}{\partial q_i'} \frac {\partial q_i'}{\partial t}=0.$$

Is it just that for this particular scenario the total and partial derivatives are equal, or am I missing something here? I've heard that the Leibniz notation breaks down somewhat here and can lead to confusion (something to do with the fact that the $\frac{\partial L}{\partial t}$'s on either side of the equation mean two totally different things); is there something that Im doing wrong?

Thanks very much for any help you can give!

3

There are 3 best solutions below

0
On

I think the main point is to always ask "how do I currently look at the function". You can always break a function to different blocks and look at it differently.

It's true that since $L = L(q_i(t),q_i'(t))$ only really depends on $t$, you can't do partial derivative on $t$, only total derivative. But you could take a partial derivative with regard to $q_i$ or $q'_i$. So the total derivative with regards to $t$ would look:

$$\frac {dL}{dt} = \frac {\partial L}{\partial q_i} \frac {dq_i}{dt} + \frac {\partial L}{\partial q_i'} \frac {d q_i'}{d t}.$$

And $\frac {\partial L}{\partial q_i}$ exist - e.g. if $L(t^2, sin(t)) = t^2sin(t)$ then $\frac{\partial L}{\partial q_i} = \frac{\partial L}{\partial t^2} = sin(t)$.

This way of mixing total and partial derivatives is used for example in the Method of Characteristics to solve the (Partial Differential) transport equation.

Now, you could decide that $q_i = t$, then you would get $L = L(t,q_i'(t))$. Now you can take the partial derivative w.r.t. $t$. It would be equal to whatever the function is, keeping $q_i'(t)$ as a constant.

e.g. if $L(t, sin(t)) = t^2sin(t)$ then $\frac{\partial L}{\partial t} = 2tsin(t)$. I.e. you keep the $sin(t)$ as a constant.

SO - your mistake is twofold:

  1. as mentioned, in the first case you computed the total derivative, not the partial (which doesn't exist w.r.t. $t$); and

  2. in the 2nd case, the partial derivative (w.r.t. $t$) is NOT equal to the total derivative (w.r.t. $t$). i.e.

$$\mathbf {\frac {\partial L}{\partial t} \neq \frac{dL}{dt}} = \frac{\partial L}{\partial t} + \frac {\partial L}{\partial q_i} \frac {d q_i}{d t} + \frac {\partial L}{\partial q_i'} \frac {d q_i'}{d t}.$$

$\frac {\partial L}{\partial t}$ in the 2nd case would mean you keep $q_i, q_i'$ as constants, and there's no further derivation for it unless you have the actual function $L$.

So, going back to my 1st point - the total derivative of $t^2 sin(t)$ will always be the same, but you may decide to break it to partial derivatives of $t$ and $sin(t)$, or $t^2$ and $sin(t)$ or something else. And sometimes these partial derivatives actually have some meanings.

0
On

Your problem comes from an abuse of notation (that is very common in this field), namely that different things are denoted with the same letters. You have a function $L$ of $2n+1$ variables, namely $$(t,q_1,\ldots, q_n,q_1',\ldots, q_n')\mapsto L(t,q_1,\ldots, q_n,q_1',\ldots, q_n')\ .\tag{1}$$ This function is given a priori, even before you know that $t$ should be time, and that, later on, the $q_i$ and $q_i'$ will be functions of $t$, whereby $q_i'(t)={d\over dt}q_i(t)$. This function $L$ has partial derivatives $${\partial L\over\partial t},\quad {\partial L\over\partial q_i},\quad {\partial L\over\partial q_i'}\ ,$$ all of them functions of the same variables given in $(1)$.

Now you start doing physics, with the already sketched interpretation of $t$. In order to do this properly we denote the "running time" with $\tau$. We then have the functions $$\tau\mapsto t(\tau)=\tau, \quad \tau\mapsto q_i(\tau),\quad \tau\mapsto q_i'(\tau):={d\over d\tau}q_i(\tau)\ .$$ Plugging these functions into $L$ we obtain a new function $$\tau\mapsto {\tt L}(\tau):=L\bigl(\tau,q_1(\tau),\ldots, q_n(\tau),q_1'(\tau),\ldots, q_n'(\tau)\bigr)\ .$$ This function ${\tt L}$ of one variable $\tau$ has a derivative $${\tt L}'(\tau)={\partial L\over\partial t}\cdot1+\sum_i{\partial L\over\partial q_i}q_i'(\tau)+\sum_i{\partial L\over\partial q_i'}q_i''(\tau)\ .$$

0
On

Complementing the good answer by Christian Blatter, the error arises because it is easy to forget that $L(\mathbf{q}(t),\dot{\mathbf{q}}(t))$ is actually a function $(t,\mathbf{q},\dot{\mathbf{q}})\mapsto L(t,\mathbf{q},\dot{\mathbf{q}})$, with $\mathbf{q}(t)=[q_1(t), q_2(t),\ldots, q_n(t)]$, and $\dot{\mathbf{q}}(t)=\left[\frac{dq_1}{dt}(t), \frac{dq_2}{dt}(t),\ldots, \frac{dq_n}{dt}(t)\right ]$, which depends on $t$, in addition to $\mathbf{q}(t)$ and $\dot{\mathbf{q}}(t)$. Therefore, the total derivative of $L$ with respect to $t$ in terms of partial derivatives is given by: $$ \frac{dL}{dt}\ =\ \frac{\partial L}{\partial t}\frac{dt}{dt} + \sum_{i=1}^n\frac{\partial L}{\partial \mathbf{q}_i}\frac{d\mathbf{q}_i}{dt} + \sum_{i=1}^n\frac{\partial L}{\partial \dot{\mathbf{q}}_i}\frac{d\dot{\mathbf{q}}_i}{dt} $$

To illustrate this, consider the following two similar examples. Both examples have similar functions, in which the co-domain is the same. However, the way the functions are expressed makes clearer in the second example the importance of the term partial derivative with respect to time.

Example 1

Consider: $$\mathbf{q}(t)\ =\ [x(t),\theta(t)],$$ $$\dot{\mathbf{q}}(t)\ =\ [\dot{x}(t),\dot{\theta}(t)],$$ and $$L(\mathbf{q}(t),\dot{\mathbf{q}}(t))\ =\ \cos(\theta(t))\dot{x}(t).$$ then, the differentiation with respec to $t$ of $L(\mathbf{q}(t),\dot{\mathbf{q}}(t))$ yields: $$\frac{dL(\mathbf{q}(t),\dot{\mathbf{q}}(t))}{dt}\ =\ -\sin(\theta(t))\dot{\theta}(t)\dot{x}(t)+\cos(\theta(t))\ddot{x}(t).$$

The partial derivatives for this example are: $$\frac{\partial L(\mathbf{q}(t),\dot{\mathbf{q}}(t))}{\partial x}\ =\ 0,$$ $$\frac{\partial L(\mathbf{q}(t),\dot{\mathbf{q}}(t))}{\partial \theta}\ =\ -\sin(\theta(t))\dot{x},$$ $$\frac{\partial L(\mathbf{q}(t),\dot{\mathbf{q}}(t))}{\partial \dot{x}}\ =\ \cos(\theta(t)),$$ $$\frac{\partial L(\mathbf{q}(t),\dot{\mathbf{q}}(t))}{\partial \dot{\theta}}\ =\ 0,$$ and $$\frac{\partial L(\mathbf{q}(t),\dot{\mathbf{q}}(t))}{\partial t}\ =\ \frac{\partial \cos(\theta)\dot{x}}{\partial t} = 0.$$ It is to be noted that in the latter partial derivative with respect to $t$, the implicit dependence on $t$ has been removed to emphasize the fact that the partial derivative is being computed with respect to the explicit variable $t$, which does not appear explicitly in $\cos(\theta)\dot{x}$ and therefore is zero.

Finally, $$\frac{dL}{dt}\ =\ \frac{\partial L}{\partial t}\frac{dt}{dt}+ \frac{\partial L}{\partial x}\frac{dx}{dt}+ \frac{\partial L}{\partial \theta}\frac{d\theta}{dt}+ \frac{\partial L}{\partial \dot{x}}\frac{d\dot{x}}{dt}+ \frac{\partial L}{\partial \dot{\theta}}\frac{d\dot{\theta}}{dt}$$ $$\frac{dL}{dt}\ =\ 0\cdot 1+ 0\cdot \dot{x}+ -\sin(\theta(t))\dot{x}(t)\cdot \dot{\theta}(t)+ \cos(\theta(t))\cdot\ddot{x}(t)+ 0\cdot \ddot{\theta}(t)$$ which is the same as the total derivative computed by differentiating $L(\mathbf{q}(t),\dot{\mathbf{q}}(t))$ directly with respecto to $t$.

Example 2

Now let's repeat a similar example, but will assume a function: $$ \phi(t,x(t),\theta(t))\ =\ \cos(\theta(t))\frac{dx}{dt}(t) $$ The total derivative of $\phi(\phi(t,x(t),\theta(t))$ with respect to time is: $$ \frac{\phi(t,x(t),\theta(t))}{dt}\ =\ -\sin(\theta(t))\frac{d\theta}{dt}(t)\frac{dx}{dt}(t) +\cos(\theta(t)\frac{d^2x}{dt^2}(t) $$ The partial derivatives are: $$\frac{\partial \phi}{\partial x}\ =\ \frac{\partial }{\partial x}\left[\cos(\theta)\frac{dx}{dt}\right ] \ =\ \cos(\theta)\frac{d}{dt}\frac{\partial x}{\partial x} \ =\ \cos(\theta)\frac{d}{dt}1 \ =\ 0,$$ $$\frac{\partial \phi}{\partial \theta}\ =\ \frac{\partial }{\partial \theta}\left [\cos(\theta)\frac{dx}{dt}\right ] \ =\ \frac{\partial \cos(\theta)}{\partial \theta}\frac{dx}{dt} \ =\ -\sin(\theta)\frac{dx}{dt},$$ and $$\frac{\partial \phi}{\partial t}\ =\ \frac{\partial }{\partial t}\left [\cos(\theta)\frac{dx}{dt}\right ] \ =\ \cos(\theta)\frac{\partial }{\partial t}\frac{dx}{dt} \ =\ \cos(\theta)\frac{d^2x}{dt^2} $$ Therefore, the total derivative of $\phi(t,x(t),\theta(t))$ with respect to $t$ expressed using the partial deriviatives is given by: $$\frac{d\phi}{dt}\ =\ \frac{\partial \phi}{\partial t} + \frac{\partial \phi}{\partial x}\frac{dx}{dt} + \frac{\partial \phi}{\partial \theta}\frac{d\theta}{dt}, $$ $$\frac{d\phi}{dt}\ =\ \cos(\theta)\frac{d^2x}{dt^2} + 0\cdot\frac{dx}{dt} + -\sin(\theta)\frac{dx}{dt}\cdot \frac{d\theta}{dt}. $$ Once again, the total derivative computed using the partial derivatives coincides, as expected, with the total derivative computed by directly differentiating $\phi(t,x(t),\theta(t))$ with respect to $t$.

Example 3: Using Python's SymPy to solve Example 2

An example is shown next to compute the total derivative of $\phi(t,x,\theta)$ using the partial derivatives using Python's SymPy package. When using this computer algebra tool for symbolic manipulation of mathematical expression in this problem, one must be careful when the partial derivative $\frac{\partial \phi}{\partial t}$ is computed, because this step requires removing the implicit dependency of $x$ and $\theta$ on $t$ to prevent the total differentiation using the chain rule of taking place and ensuring the actual partial derivative is computed with respect to $t$.

import sympy as sp
from sympy import sin, cos, Function

sp.init_printing()
                    
t = sp.symbols('t') # Create symbol for time t
x     = sp.Function('x')     # Create functions x and theta
theta = sp.Function('theta') 

# Now the function phi(x(t),theta(t)) is created:
#    phi = cos(theta(t))*(dx(t)/dt)
# A typical mistake is to believe that phi is a function only of theta and x
# when it is actually a fucntion phi: t,x,theta -> phi(t,x,theta)
#
print('\n phi(x,theta): ') 
phi = cos(theta(t))*sp.diff(x(t),t)
sp.pprint(phi)

# Now compute the partial derivative of phi with resepct to x.
# Observe differentiation is carried out with respect to 'x(t)' and not
# with respect to 'x', since x was declared to be a function and not a symbol. 
phi_partial_x = sp.diff(phi,x(t))
print('\n dp phi/dp x: ') 
sp.pprint(phi_partial_x)

# Next compute the partial derivative of phi with resepct to theta.
# Similarly, observe differentiation is carried out with respect to 'theta(t)' and not
# with respect to 'theta', since theta was declared to be a function and not a symbol.
print('\n dp phi/dp theta: ') 
phi_partial_theta = sp.diff(phi,theta(t))
sp.pprint(phi_partial_theta)


# Finally, compute the partial derivative of phi with respecto to t:
phi_partial_t = sp.diff(phi.subs([(theta(t),sp.Symbol('theta'))]),t).subs([(sp.Symbol('theta'),theta(t))])
print('\n dp phi/dp t: ') 
sp.pprint(phi_partial_t)

# We can express the total derivative of phi with resepct to time in terms of
# the partial derivatives as:
#
#    dphi/dt = (dp phi/dp t) + (dp phi/dp x)*dx/dt + (dp phi/dp theta)*dtheta/dt
# 
# where dp represents the partial derivative.
#
# WARNING: It is a mistake to believe that phi = f(x, theta) is a function f of 
#          x and theta withtout specifing the implicit dependency on t and forget
#          the term (dp z/dp t):
#
#    dphi/dt IS NOT = (dp z/dp x)*dx/dt + (dp z/dp theta)*dtheta/dt
# 
phi_dot_1 = phi_partial_t + phi_partial_x*sp.diff(x(t),t) + phi_partial_theta*sp.diff(theta(t),t)
print('\n dphi/dt = (dp phi/dp t) + (dp phi/dp x)*dx/dt + (dp phi/dp theta)*dtheta/dt : ')
sp.pprint(phi_dot_1)

# We could have also computed the total derivative by differentiating phi directly
# with repect to t: 
phi_dot_2 = sp.diff(phi,t)
print('\n dphi/dt: ')
sp.pprint(phi_dot_2)

print('CAUTION: It can be verified that the total derivative computed directly by differentiating phi with respect to t and the version computed from the partial derivatives coincide as expected.  However, observe that the computation of the partial derivative (dp phi/dp t) required substitutions to remove the dependencies of x and theta on t, expect in the derivative of x with respect to t, in order to PARTIALLY differentiate ONLY with respect to t and not with respect to the variables that depend on t!')
 
print('--------------------------------------------------')

```