Artificial intelligent assistant

How to take partial derivative with respect to a derivative? I have a Hamiltonian function, $H(p,q)$ which is a function of $p$ and $q$: $$H(p,q) = p^2 + q^2$$ and I also have a Lagrangian via the Legendre transformation which is $$L(q,\dot q) = p \dot q - H(p,q) = p \dot q - p^2 - q^2$$ I want to find the costate $p$, which is a function like this: $$ p = \frac{\partial L}{\partial \dot q}$$ From the Hamiltonian dynamics, I know that $$\dot q = \frac{\partial H(p,q)}{\partial p} = 2p$$ So, in this case, what is $p$, since it is a partial derivative of the $L(q,\dot q)$? **EDIT** : Is it $p =\frac{\partial L}{\partial \dot q}= \frac{1}{2}[\dot q - 2 p]$ ?

The notation here is slightly confusing. $L$ is really just a function of three _a priori_ unrelated variables. Consequently $\frac{\partial L}{\partial \dot{q}}$ is just the partial derivative with respect to the third argument of $L$, which in your case is just $p$. The fact that the third argument is the time derivative of the second argument doesn't come into play at this stage.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 45f9b5ecba06b438dba5109ed938ea46