I am relatively new to Lagrangian and Hamiltonian dynamics. I am aware of how to form the equations of motion using the Legendre Transformation. I, however, have one fundamental question and I was hoping if someone could help me with this.
On performing the Legendre transformation $$H = p^T\dot{q} - L \tag{1}$$ where $p$ is the conjugate momenta, I was under the impression that $p$ and $q$ would be independent variables. However, using $$p = \frac{\partial L}{\partial \dot{q}}\tag{2}$$ gives $p=p(q,\dot{q})$, which implies that $p$ and $q$ are not independent. Is this a non-canonical transformation? Or am I doing something wrong? How do I work around this?