Notes
2026-10-30
some issues in efficiency in the code: integration and analysis are two for-loops
integration:
function surface_section_x0(sol; x_cut=0)
ys, pys = Float64[], Float64[]
for i in 2:length(sol.t)
x_prev = sol[1, i-1]
x_curr = sol[1, i]
if x_prev < x_cut && x_curr >= x_cut
# linear interpolation to x=0 crossing
α = -x_prev / (x_curr - x_prev)
y = sol[2, i-1] + α * (sol[2, i] - sol[2, i-1])
py = sol[4, i-1] + α * (sol[4, i] - sol[4, i-1])
push!(ys, y)
push!(pys, py)
end
end
ys, pys
endchecks every saved value of the integration if \(x(t)<0\) and \(x(t+\tau)\geq 0\)
inefficient due to iterating though both bodies at once
Solution:
using the function
This gets then implemented by 1) initializing the surface of section arrays, 2)