Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created May 11, 2017 06:50
Show Gist options
  • Select an option

  • Save idontgetoutmuch/84ff123ea718c77492d3ff0b80b1e978 to your computer and use it in GitHub Desktop.

Select an option

Save idontgetoutmuch/84ff123ea718c77492d3ff0b80b1e978 to your computer and use it in GitHub Desktop.
e = 0.6
q10 = 1 - e
q20 = 0.0
p10 = 0.0
p20 = sqrt((1 + e) / (1 - e))
h = 0.1
dummyStart = ((q10, q20), (p10, p20))
function oneStep2(h, prev)
h2 = h / 2
qsPrev = prev[1]
psPrev = prev[2]
function nablaQ(qs)
q1 = qs[1]
q2 = qs[2]
r = (q1^2 + q2^2) ^ (3/2)
return (q1 / r, q2 / r)
end
function nablaP(ps)
return ps
end
p2 = psPrev - h2 * nablaQ(qsPrev)
qNew = qsPrev + h * nablaP(p2)
pNew = p2 - h2 * nablaQ(qNew)
return (qNew, pNew)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment