Take the 2-minute tour ×  many textbooks tell me that
Hamiltonians are constructed from Lagrangians like
$$L=L(q,\dot{q})$$ with a Legendre transformation to obtain the
Hamiltonian as $$H=\dot{q}\frac{\partial L}{\partial
\dot{q}}-L$$ but none of the textbooks explain how this is done.
My specific problem is that I have Lagrangians that do not
depend on $\dot{q}$ and therefore should have $\frac{\partial
L}{\partial \dot{q}}=0$, hence $H=-L$. But my impression from
the clues I have is that it is not that simple.  Let's say the
Lagrangian is $$L(q)=\ln(q)-(2q-10)\lambda$$ Now as far as I
know the Legendre transformation should give a function
$f^*(p)=\sup(pq-L(q))$ (this implies $p=\frac{\partial
L}{\partial q}$) which is obtained by substituting the
stationary point $q_s$ of $\sup(pq-L(q))$ into $pq-L(q)$ thus
getting $f^*(p)=pq_s-L(q_s)$ (for instance wikipedia's Legendre
Transformation page explains this). Doing this for the example
above: $$\frac{\partial (pq-L(q))}{\partial q}=\frac{\partial
(pq-\ln(q)+(