I am reading a book about classical mechanics. In the chapter about chaos, it gives the simplified and scaled equations for double pendulum as
$$ \frac{d}{dt}\left[ \begin{matrix} \alpha \\[3mm] l_\alpha \\[3mm] \beta \\[3mm] l_\beta \end{matrix} \right] = \left[ \begin{matrix} 2\frac{l_\alpha - (1+\cos\beta)l_\beta}{3-\cos 2\beta} \\[2mm] -2\sin\alpha - \sin(\alpha + \beta) \\[2mm] 2\frac{-(1+\cos\beta)l_\alpha + (3+2\cos\beta)l_\beta}{3-\cos2\beta}\\[2mm] -\sin(\alpha+\beta) - 2\sin\beta\frac{(l_\alpha-l_\beta)l_\beta}{3-\cos2\beta} + 2\sin2\beta\frac{l_\alpha^2-2(1+\cos\beta)l_\alpha l_\beta + (3+2\cos\beta)l_\beta^2}{(3-\cos2\beta)^2} \end{matrix} \right] $$
I am going to plot the Poincaré section, which in this case is the collection of $(\beta, l_\beta)$ when $\alpha=0$ and $d\alpha/dt >0$. I follow the code found in the example of Mathematica for Poincaré section and write the following code
abc = {a'[t] == 2*(la[t] - (1 + Cos[b[t]])*lb[t])/(3 - Cos[2*b[t]]),
la'[t] == -2*Sin[a[t]] - Sin[a[t] + b[t]],
b'[t] == 2*(-(1 + Cos[b[t]])*la[t] + (3 + 2*Cos[b[t]])*lb[t])/(3 - Cos[2*b[t]]),
lb'[t] == -Sin[a[t] + b[t]] - 2*Sin[b[t]]*((la[t] - lb[t])*lb[t])/(3 - Cos[2*b[t]]) +
2*Sin[2*b[t]]*(la[t]^2 - 2*(1 + Cos[b[t]])*la[t]*lb[t] +
(3 + 2*Cos[b[t]])*lb[t]^2)/(3 - Cos[2*b[t]])^2};
psect[{a0_, la0_, b0_ , lb0_}] :=
Reap[NDSolve[{abc, a[0] == a0, la[0] == la0, b[0] == b0, lb[0] == lb0,
WhenEvent[a[t] == 0 && la'[t]>0, Sow[{b[t], lb[t]}]]}, {},
{t, 0, 1000}, MaxSteps -> ∞]][[-1, 1]]
abcdata = Map[psect, {{0.01, 0.01, 0.01, 0}, {0.01, 0.01, 0.01, 0.01},
{0.01, 0.01, 0.01, -0.01}}];
ListPlot[abcdata, ImageSize -> Medium]
Here a is $\alpha$, b is $\beta$, la is $l_\alpha$ and lb is $l_\beta$. I don't know why, they code has two problems. First the condition "la'[t]>0" doesn't work. Secondly, even I remove the condition "&& la'[t]>0", it sill reports that error code like "NDSolve::deqn: Equation or list of equations expected instead of 0.01` in the first argument". I spent quite a long time to figure out the problem but I still cannot find out the reason.
Here is plot for the Poincaré section from the book I am reading (I redraw with image editor).
lb[0] = lb0
which is given away by the fact thatlb
is coloured black, as well as by Mathematica seeing a number where there should be an equation. Use==
. $\endgroup$