#### @J.G. 2017-05-18 13:21:57

The problem here is that, because there exist constraints of the form $f(q,\,p)=0$, the phase space coordinates of the usual Hamiltonian formulation aren't independent. I'm not sure how you encountered this Lagrangian, but this issue is a common hiccup in electromagnetism and (if you'll pardon a more obscure example) BRST quantisation. The good news is you can still form a Hamiltonian description equivalent to the Lagrangian one. The trick is to append suitable terms to the "naïve" Hamiltonian, as explained here, and as a result the Poisson brackets are upgraded to what are called Dirac brackets.

For your problem the full Hamiltonian is $H=-2\theta^2+c_1 p_\eta+c_2( p_\theta-\eta)$, where the $c_i$ remain to be computed as functions of undifferentiated phase space coordinates. In fact $c_1=\frac{\partial H}{\partial p_\eta}=\dot{\eta}=4\theta$ while $c_2=\frac{\partial H}{\partial p_\theta}=\dot{\theta}=0$, so $H=-2\theta^2+4\theta p_\eta$. You can verify this gives you the right equations of motion.

#### @donnydm 2017-05-18 14:39:36

Thanks! It's actually a part of perturbed NLS Lagrangian after an attempt of finding solution using variational method. Are the Dirac's procedure covers all Lagrangian of 'irregular' forms?

#### @J.G. 2017-05-18 16:07:28

@donnydm Given any Lagrangian with consistent equations of motion, this technique will ensure an equivalent Hamiltonian formulation, although if there are higher-order derivatives you also need a trick due to Ostrogradski. (An example of an inconsistent Lagrangian is $L=q$.)