1

If I have the following Hamiltonian:

1/2 k q[t]^2 + Derivative[1][q][t] (m Derivative[1][q][t] + y q[t]) - 
1/2 m Derivative[1][q][t]^2 - y q[t] Derivative[1][q][t] 

and I have for p:

p = y q[t] + m Derivative[1][q][t]

How can I substitute p in order to eliminate q'[t]?

Kuba
  • 136,707
  • 13
  • 279
  • 740
ame_math
  • 99
  • 4

1 Answers1

4

If you aim to exclude the derivative, try this:

     1/2 k q[t]^2 + Derivative[1][q][t] (m Derivative[1][q][t] + y q[t]) - 
   1/2 m Derivative[1][q][t]^2 - y q[t] Derivative[1][q][t] /. 
  q'[t] -> p/m - y/m*q[t] // Simplify

(* (p^2 - 2 p y q[t] + (k m + y^2) q[t]^2)/(2 m)  *)

If, on the other hand, you aim to exclude the q[t], try this:

1/2 k q[t]^2 + Derivative[1][q][t] (m Derivative[1][q][t] + y q[t]) - 
   1/2 m Derivative[1][q][t]^2 - y q[t] Derivative[1][q][t] /. 
  q -> (p - y/m*q'[#] &) // Simplify

(*  (k m^2 p^2 - 2 k m p y Derivative[1][q][t] + 
 k y^2 Derivative[1][q][t]^2 + m y^2 (q^\[Prime]\[Prime])[t]^2)/(2 m^2)   *)

Have fun!

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96