# Partial differentiation mixes up variables

Consider $$U \equiv \dot{\theta} - \theta \ ,$$

where as per usual $\dot{\theta} = \frac {d \theta}{dt}$. We then have $$\frac {\partial U}{\partial \theta} = -1 \quad , \quad \frac {\partial U}{\partial \dot{\theta}} = 1$$

Here is what happens if we try to compute the former partial derivative in Mathematica: Of course, one work-around is to replace $\theta$ with say $x$ but that becomes cumbersome, especially when one has a lengthy and convoluted expression.

Anyone know how to resolve this?

EDIT: What I want to achieve is that Mathematica recognizes the two different involved quantities as two fundamentally different variables. Say we had $U \equiv \stackrel{lol}{\theta} - \theta$. Then Same issue.

You need to define OverDot[\[Theta]] to be the derivative of \[Theta] with respect to some variable t; otherwise there is no way for Mathematica to know the relation between \[Theta] and OverDot[\[Theta]].

OverDot[\[Theta][t_]] := D[\[Theta], t];


Then

D[OverDot[\[Theta][t_]]- \[Theta], \[Theta]]


-1

and

D[OverDot[\[Theta][t_]]- \[Theta], Overdot[\[Theta][t]]


1.

• The point is it does not necessarily have to be defined as the derivative of $\theta$. Say the expression is $\stackrel{cool}{\theta} - \theta$. The same problem arises. The point is I want Mathematica to recognize $\stackrel{cool}{\theta}$ and $\theta$ as two completely different variables. – user23366 Dec 25 '14 at 20:36