# Hamiltonian System with NDSolve

1. Apr 23, 2008

### Grandpa

So I'm trying to solve the following Hamiltonian system using Mathematica.

solution = NDSolve[{x'[t] == 2p[t], x[0] == 2,
p'[t] == I*(2 + 1/2)(I*x[t])^(1 + 1/2), p[0] == 1-2*I}, {x, p}, {t,0,10}, MaxSteps -> Infinity][[1]];

I'm letting E=1, so at all points t, it should be that
(p[t]/.solution)^2-(I*x[t]/.solution)^(2+1/2)=1.

That is the case until the function crosses a branch cut on the complex x-plane that runs from 0 to i*(Infinity). Once the function crosses the branch cut, the system no longer preserves E and the value changes to something around 1.3.

How can I go about fixing this problem? I've already tried working with the precision and accuracy goals, and that didn't work. I also tried the SymplecticPartitionedRungeKutta method, and that didn't work either. I'm not sure what else to consider. Any help would be appreciated.

I was thinking about having the program just continue in the same direction when x[t] gets really near the branch cut, but I'm not sure what to use to program that.

Thanks,
Alex