# Can we write a Lagrangian for the classical system with $H=kqp$?

Say we have the following Lagrangian:

$$H = kqp.$$

The equations of motion are easy to find:

$$\dot{q} = kq \\ \dot{p} = -kp,$$

and to solve:

$$q=q_0 e^{kt} \\ p=p_0 e^{-kt}.$$

I'm curious if we can write a meaningful Lagrangian for this system, and if not, why not?

$$H(q,p,t) = p\dot{q} - L(q,\dot{q},t)$$

so the Lagrangian should equal

$$p\dot{q} - kqp$$

To get $L(q,\dot{q},t)$, we must write $p$ in terms of $q$ and $\dot{q}$. Using the explicit solutions above, there are two ways we can do this:

$$p = p_0 q_0/q$$ or $$p = p_0 q_0 k/\dot{q}$$

I suppose the most general form is: $$p = p_0 q_0(\alpha/q + \beta k/\dot{q})$$ with $\alpha+\beta=1$. Substituting $p$ with this expression, then removing constants and constant factors, we get:

$$L \sim \alpha \dot{q}/q - \beta k^2 q/\dot{q}.$$

Now:

$$\frac{\partial L}{\partial q} = -\frac{\beta k^2}{\dot{q}} - \frac{\alpha \dot{q}}{q^2} \\ \frac{d}{dt} \frac{\partial L}{\partial \dot{q}} = \frac{\beta k^2}{\dot{q}} - \frac{\alpha \dot{q}}{q^2} - \frac{2\beta k^2 q \ddot{q}}{\dot{q}^3}$$

So the Euler-Lagrange equation gives us: $$\dot{q}^2 = q \ddot{q}$$ The solution here is $q=e^{wt}$ for all $w$, instead of just for $w=k$, disagreeing with the solution to Hamilton's equations.

Furthermore, if we had chosen $\beta=0$ above, we would have $L \sim \dot{q}/q$, which gives an Euler-Lagrange equation of $0=0$.

What is going on here? I feel like I probably did something illegitimate when deriving the Lagrangian from the Hamiltonian, but I don't know exactly what.

Is this particular Hamlitonian just illegitimate to start out with? Is it just not possible to use the Lagrangian formalism with this system? Is there any Lagrangian that will give equations of motion $\dot{q} = k q$ (or, more likely, $\ddot{q} = k \dot{q}$)?

Finally, does any of this matter? Is there any imaginable physical systems where we can define a coordinate $q$ such that $H\sim qp$ or $L\sim q/\dot{q}$ or $L\sim \dot{q}/q$?

1. The Hamiltonian action is $$S_H[q,p]~=~\int\!dt~L_H(q,\dot{q},p,t), \tag{1}$$ $$L_H(q,\dot{q},p,t)~:=~ p\dot{q}-H(q,p,t)~=~p(\dot{q}-kq), \tag{2}$$ $$H(q,p,t)~:=~kqp. \tag{3}$$ The EL equations for the action (1) are Hamilton's equations.
2. We see that the variable $p$ serves as a (dynamical) Lagrange multiplier in the Hamiltonian action (1), which imposes the condition $$\dot{q}~\approx~\frac{\partial H}{\partial p}~=~kq. \tag{4}$$
3. Regular Legendre transformation breaks down because we cannot solve for $p$ in the condition (4), as OP already remarked. Hence the Hamiltonian Lagrangian (2) should be viewed as a Lagrangian that results from a singular Legendre transformation of the Hamiltonian (3), with momentum variable $p$ demoted to the status of a (dynamical) Lagrange multiplier.
Here's your error. You used the incorrect equation. So, we go back to the the point in the Legendre transform just before the mistake $$L = p\dot{q} - H.$$ The next step is use not a solution to the equations of motion, but the equations of motion themselves to find $p$ in terms of $\dot{q}$ (and $q$, potentially). In this case, where Hamilton's equation of motion yields $$\dot{q} = kq,$$ we don't have a relationship between $\dot{q}$ and $p$ that can be solved for $p$, so the Legendre transform is simply not possible.