powered by
Approximates Hamiltonian dynamics for some potential function and a L2-norm kinectic funcion, assuming H(q,p) = U(q) + K(p).
hamiltonian_dynamics(U, q, p, L, eps, m)
Potential function of the system.
Initial position vector.
Initial momentum vector.
Number of steps.
Size of each step.
Mass vector.
A list with the position `q` and momentum `p` at the end of the trajectory.
# NOT RUN { U = function(x) exp(-0.5 * x^2) / sqrt(2 * pi) hamiltonian_dynamics(U, -2, 0.8, 100, 0.1, 1) hamiltonian_dynamics(U, -2, 0.85, 100, 0.1, 1) # }
Run the code above in your browser using DataLab