# Partial derivatives in Lagrangian formalism [duplicate]

Suppose I have a function $f = xy$. A partial derivative of $f$ with respect to $x$ implies holding $y$ constant:

$$\frac{\partial f}{\partial x} = y$$

Does this mean that in order to evaluate this derivative, $y$ cannot depend on $x$? For example, if $y = x$ then

$$\frac{\partial f}{\partial x} = \frac{\partial (x^2)}{\partial x} = 2x$$

Which is inconsistent with the first calculation of $\frac{\partial f}{\partial x}$.

If $y$ indeed cannot depend on $x$, then how does the Lagrangian formalism of classical mechanics make sense? The Lagrangian is a function of $q$ and $\dot{q}$, and when we evaluate $\frac{\partial L}{\partial \dot{q}}$ we 'ignore' all of the $q$ dependence, even though $\dot{q}$ is a function of $q$.

• possible duplicate of Why does calculus of variations work? – Danu Jul 4 '14 at 19:18
• Normally, the second way of calculating would be correct. However, in the Lagrangian formalism the velocity and position still appear as independent variables; they are not quite varied independently, as explained in the question I linked in the above comment. – Danu Jul 4 '14 at 19:49