How to solve for Hamiltonian gradient?

In summary, Hamiltonian gradient is a method used to solve classical mechanics problems by approximating derivatives in Hamilton's equations through finite differences. This method requires a set of initial conditions for position and momentum, and iteratively generates solutions at later times. The step size used in the finite differences can impact the stability and accuracy of the results, with smaller steps potentially leading to more stable solutions. The behavior of the solutions will depend on the form of the potential used in the equations.
  • #1
kulimer
9
0
I am trying to understand how Hamiltonian gradient works.

[itex]H(q,p)=U(q)+K(p)[/itex]

U(q): potential energy
K(p): kinetic energy
q: position vector
p: momentum vector
both p and q are functions of time
H(q,p): total energy

[itex]\frac{d{{q}_{i}}}{dt}=\frac{\partial H}{\partial {{p}_{i}}}[/itex]
[itex]\frac{d{{p}_{i}}}{dt}=-\frac{\partial H}{\partial {{q}_{i}}}[/itex]
Now, I am trying to solve this (the technical name is called leapfrog method)

[itex]{p}_{i}(t+\varepsilon /2)={p}_{i}(t)-(\varepsilon /2)\frac{\partial U}{\partial {q}_{i}}(q(t))[/itex]

[itex]{q}_{i}(t+\varepsilon )={q}_{i}(t)+\varepsilon \frac{{p}_{i}(t+\varepsilon /2)}{m}[/itex]

[itex]{p}_{i}(t+\varepsilon )={p}_{i}(t+\varepsilon /2)-(\varepsilon /2)\frac{\partial U}{\partial {q}_{i}}(q(t+\varepsilon ))[/itex]​
 
Last edited:
Physics news on Phys.org
  • #2
Hi Kulimer,

It looks to me like your doing classical rather than quantum mechanics. But anyway, basically the equations you've got there are just expanding the derivatives in Hamilton's equations in a finite difference approximation. Anyway, the way to solve all such problems is iteratively. From the particular finite difference approximation taken, (and assuming you know U(q) at all q), you need a pair of boundary conditions, to specify vectors [itex](p_i,q_i)[/itex] at a particular point in time. Let's say [itex] (p_i(0),q_i(0))[/itex]. Then start off at this time and use it with the finite difference equations to generate (p,q) at later times. So consider,

[itex]p_i(0+\epsilon/2)=p_i(0)-(\epsilon/2)*\frac{\partial U}{\partial q_i}(q_i(0)) [/itex]

Note that with the boundary condition you know the complete left hand side of this equation. Once you know this, you can solve the second equation at [itex] 0+\epsilon [/itex], then the third equation. Then you can use the solutions of these equations to solve the set of equations at the next step in time, and keep generating terms for as long as you like.

Note this isn't the sort of thing you'd want to do by hand. A few loops or a spreadsheet if you've not done programming before.

Out of interest, why is finite difference in momentum half that it is in position? If [itex]\epsilon[/itex] it would be easier just to have do momentum and position on the same spacing, but then there may be a good reason.

Hope this helps.
 
  • #3
Thanks for your answer.
Should I move this thread to classical physics? Maybe you know how?
Out of interest, why is finite difference in momentum half that it is in position?
This is actually a discrete estimation of Hamiltonian using leapfrog.

As pointed out here on page 8
http://www.cs.toronto.edu/~radford/ftp/ham-mcmc.pdf

But it didn't explicitly say what are the partial derivatives.
I simulated 20 numbers, the pair of numbers (position, momentum), they keep on getting larger, which is weird.

Does this look right to you? I am no physics genius on this. Hope you could let me know if I am doing the right thing.

First column: position
Second column: momentum

[1,] 0.2194610 0.7644557
[2,] 0.4586734 0.8661759
[3,] 0.7391665 1.0458519
[4,] 1.0861846 1.3196545
[5,] 1.5309592 1.7122261
[6,] 2.1135202 2.2588980
[7,] 2.8862981 3.0088708
[8,] 3.9188427 4.0296419
[9,] 5.3040832 5.4130808
[10,] 7.1666912 7.2836969
[11,] 9.6743014 9.8098458
[12,] 13.0525987 13.2188808
[13,] 17.6056299 17.8176151
[14,] 23.7431677 24.0199348
[15,] 32.0175907 32.3840485
[16,] 43.1735969 43.6627267
[17,] 58.2152267 58.8710502
[18,] 78.4962270 79.3777683
[19,] 105.8418877 107.0284855
[20,] 142.7133183 144.3117664
 
Last edited:
  • #4
Yeah, I can see it could be more stable if the step size were smaller. It would especially make sense if the potential was a slower in q than in p. The thing is, for most introductory examples, computation time isn't really a problem so you can take [itex]/epsilon[/itex] to be really small and do more steps then it is easier (and potentially stabler) to use the Euler method, because it's clearer precisely what's going on (it really is just a finite approximation of the derivatives in Hamilton's equations), it's also then easier to plot (p,q) behaviour.

I do concede though, as you get to more complicated examples (especially if you have more dimensions to worry about), computation speed may become an issue at some point and such optimisations may be useful (i.e. for precisely the sort of problems discussed in the rest of the article!)

As for making sense of the results, it's rather going to depend on the form of U! If you've used the Harmonic potential as in the article, so
[itex] U = q^2 /2 [/itex]
Then this is the incorrect behaviour, you would expect oscillations (like in the article, where (p,q) forms a circle, if you've got the other sign however, so
[itex] U = -q^2 /2 [/itex]
Then the exponential growth is the correct behaviour. So what is the potential in question?
 

Related to How to solve for Hamiltonian gradient?

1. How is the Hamiltonian gradient defined?

The Hamiltonian gradient is defined as the vector of partial derivatives of the Hamiltonian function with respect to its variables. It represents the direction and magnitude of the steepest ascent or descent of the Hamiltonian function.

2. What is the purpose of solving for the Hamiltonian gradient?

Solving for the Hamiltonian gradient is important in many areas of physics and engineering, as it allows for the determination of the optimal path or trajectory for a system to follow to minimize or maximize the Hamiltonian function.

3. What are the key steps in solving for the Hamiltonian gradient?

The key steps in solving for the Hamiltonian gradient include defining the Hamiltonian function, calculating the partial derivatives of the Hamiltonian function with respect to its variables, and then combining these derivatives into a vector to obtain the Hamiltonian gradient.

4. Are there any specific techniques or methods for solving for the Hamiltonian gradient?

Yes, there are various techniques and methods for solving for the Hamiltonian gradient depending on the specific problem at hand. Some common techniques include gradient descent, stochastic gradient descent, and conjugate gradient descent.

5. What are some applications of solving for the Hamiltonian gradient?

Solving for the Hamiltonian gradient has many applications, including in quantum mechanics, classical mechanics, control theory, and machine learning. It can also be used to optimize various systems, such as in determining the optimal trajectory for a spacecraft or the optimal control inputs for a robot.

Similar threads

Replies
1
Views
1K
Replies
11
Views
1K
Replies
1
Views
1K
Replies
3
Views
898
  • Quantum Physics
Replies
5
Views
738
Replies
7
Views
1K
  • Quantum Physics
Replies
6
Views
1K
  • Quantum Physics
Replies
13
Views
747
  • Quantum Physics
Replies
4
Views
900
Replies
17
Views
2K
Back
Top