Trajectories of system of parametric equations

I have to obtain plots of trajectories for (theta(t),u(t)) and then overlay them with a contour plot. The overlaying with the contour plot it is easy. What trubles me though is the trajectory part.

First, I solve the system, then I do a simple plot for the values and finally a parametric plot as follows:

s = NDSolve[{Theta'[t] == u[t], u'[t] == -Sin[Theta[t]],
Theta[0] == 0, u[0] == 1.5}, {Theta, u}, {t, -4 Pi, 4 Pi}]

Plot[Evaluate[{Theta[t], u[t]} /. s], {t, -4 Pi, 4 Pi},
PlotLegends -> {"Theta[t]", "u[t]"}, AxesLabel -> {t, E[t]},
LabelStyle -> Directive[Blue, Bold]]

ParametricPlot[Evaluate[{Theta[t], u[t]} /. s], {t, -4 Pi, 4 Pi}]

Show[ContourPlot[(1/2) u^(2) + 1 - Cos[Theta], {Theta, -4 Pi,
4 Pi}, {u, -5, 5}],
ParametricPlot[Evaluate[{Theta[t], u[t]} /. s], {t, -4 Pi, 4 Pi}]]


After getting the the parametric plot, using Show[...] I combine it with the contour one. Instead of recurring at every closed contour, it appears only once.

Do I have to use a different kind of plotting to have it repeatedly?

• I don't see a ContourPlot in your code. Where is the contour plot? And what do you mean by "Instead of recurring at every closed contour, it appears only once."? Commented Oct 10, 2015 at 3:34
• I used this: Show[ContourPlot[(1/2) u^(2) + 1 - Cos[Theta], {Theta, -4 Pi, 4 Pi}, {u, -5, 5}], ParametricPlot[Evaluate[{Theta[t], u[t]} /. s], {t, -4 Pi, 4 Pi}]] to combine the contour plot and the parametric above, and when I do the parametric appears inside a closed contour only once. Should it appear more times, since it states "trajectory" shouldn't it repeat? @march Commented Oct 10, 2015 at 3:39
• For the un-damped, non-driven pendulum, the contours of constant energy are exactly the trajectories in phase space. For this reason, you could just use the solution from here. Your different trajectories (the different closed-curve ellipses) all represent the same trajectory, actually, since really, $-\pi/2\leq\theta \leq \pi/2$, so you really only need to plot in this region. Commented Oct 10, 2015 at 4:58

s = ParametricNDSolveValue[{th'[t] == u[t], u'[t] == -Sin[th[t]],
th[0] == i, u[0] == 1.5}, {th, u}, {t, -4 Pi, 4 Pi}, {i}]
Show[
ContourPlot[(1/2) u^(2) + 1 - Cos[th], {th, -4 Pi, 4 Pi}, {u, -5, 5},
ColorFunction -> "Pastel"],
ParametricPlot[Through[s[#][t]], {t, -4 Pi, 4 Pi}] & /@ Pi Range[-4, 4, 2]]


• Thanks again :) answer exactly on point! Commented Oct 10, 2015 at 4:15
• I am having a problem with the ParametricPlot portion. I'm on 10.2 and started a new Mathematica and copied and executed your code. The ParametricPlot has a problem. I ran a test replacing ParametricPlot with Table. This Table[Through[s[#][t]], {t, -4 Pi, 4 Pi}] & /@ Pi Range[-4, 4, 2] produces {-4 \[Pi], -2 \[Pi], 0, 2 \[Pi], 4 \[Pi]}. However when I write it out a bit more Map[ (Table[Through[s[#][t]], {t, -4 \[Pi], 4 \[Pi]}]) &, Pi Range[-4, 4, 2] ] I get the right answer. I am a bit lost. Commented Oct 10, 2015 at 21:34
• This works Show[ ContourPlot[(1/2) u^(2) + 1 - Cos[th], {th, -4 Pi, 4 Pi}, {u, -5, 5}, ColorFunction -> "Pastel"], Map[ (ParametricPlot[Through[s[#][t]], {t, -4 \[Pi], 4 \[Pi]}]) &, Pi Range[-4, 4, 2] ] ] Commented Oct 10, 2015 at 21:37