\( \DeclareMathOperator{\abs}{abs} \newcommand{\ensuremath}[1]{\mbox{$#1$}} \)

Non-linear Differential Equations of Motion for tutorial2x.py

Provided herein is the wxMaxima derivation of a discrete state representation in the form Y' = Ainv*G(y,y') for non-linear differential equations of motion of the double pendulum system described for problem 6.4 presented on page 276 of reference [1].

References:

  [1] Greenwood, Donald T., "Principles of Dynamics". Englewood Cliffs, N.J.: Prentice-Hall, Inc., 1965.

The following two cells present the non-linear differential equations of motion given on page 505 of reference [1] as solution (a) to problem 6-4 presented on page 276 of same reference.

--> m·l^2·((3+2·cos(φ))·'diff(θ,t,2)+(1+cos(φ))·'diff(φ,t,2)sin(φ)·('diff(φ,t,1)^2+2·'diff(θ,t,1'diff(φ,t,1)))+m·g·l·(2·sin(θ)+sin(θ+φ))=0;
\[\tag{%o21} g l m\, \left( \sin{\left( \phi +\theta \right) }+2 \sin{\left( \theta \right) }\right) +{{l}^{2}} m\, \left( \left( \cos{\left( \phi \right) }+1\right) \, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \phi \right) -\sin{\left( \phi \right) } \left( {{\left( \frac{d}{d t} \phi \right) }^{2}}+2 \left( \frac{d}{d t} \theta \right) \, \left( \frac{d}{d t} \phi \right) \right) +\left( \frac{{{d}^{2}}}{d {{t}^{2}}} \theta \right) \, \left( 2 \cos{\left( \phi \right) }+3\right) \right) =0\]
--> m·l^2·((1+cos(φ))·'diff(θ,t,2)+'diff(φ,t,2)+'diff(θ,t,1)^2·sin(φ))+m·g·l·sin(θ+φ)=0;
\[\tag{%o4} g l m \sin{\left( \phi +\theta \right) }+{{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \phi +{{\left( \frac{d}{d t} \theta \right) }^{2}} \sin{\left( \phi \right) }+\left( \frac{{{d}^{2}}}{d {{t}^{2}}} \theta \right) \, \left( \cos{\left( \phi \right) }+1\right) \right) =0\]

This pair of differential equations are expanded to group terms containing 2nd derivatives of Theta and Phi in order to transform the above two equations into the form A*Y' = G(y,y').

--> expand(m·l^2·((3+2·cos(φ))·'diff(θ,t,2)+(1+cos(φ))·'diff(φ,t,2)sin(φ)·('diff(φ,t,1)^2+2·'diff(θ,t,1'diff(φ,t,1)))+m·g·l·(2·sin(θ)+sin(θ+φ)));
\[\tag{%o8} g l m \sin{\left( \phi +\theta \right) }+{{l}^{2}} m \cos{\left( \phi \right) } \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \phi \right) +{{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \phi \right) -{{l}^{2}} m \sin{\left( \phi \right) } {{\left( \frac{d}{d t} \phi \right) }^{2}}-2 {{l}^{2}} m\, \left( \frac{d}{d t} \theta \right) \sin{\left( \phi \right) } \left( \frac{d}{d t} \phi \right) +2 {{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \theta \right) \cos{\left( \phi \right) }+3 {{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \theta \right) +2 g l m \sin{\left( \theta \right) }\]
--> expand(m·l^2·((1+cos(φ))·'diff(θ,t,2)+'diff(φ,t,2)+'diff(θ,t,1)^2·sin(φ))+m·g·l·sin(θ+φ));
\[\tag{%o10} g l m \sin{\left( \phi +\theta \right) }+{{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \phi \right) +{{l}^{2}} m\, {{\left( \frac{d}{d t} \theta \right) }^{2}} \sin{\left( \phi \right) }+{{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \theta \right) \cos{\left( \phi \right) }+{{l}^{2}} m\, \left( \frac{{{d}^{2}}}{d {{t}^{2}}} \theta \right) \]

The elements of the A matrix are coefficients of terms containing 2nd derivatives of Theta and Phi as presented below.

--> A: matrix(
[2·l^2·m·cos(φ)+3·l^2·m,l^2·m·cos(φ)+l^2·m],
[l^2·m·cos(φ)+l^2·m,l^2·m]
);
\[\tag{A}\begin{pmatrix}2 {{l}^{2}} m \cos{\left( \phi \right) }+3 {{l}^{2}} m & {{l}^{2}} m \cos{\left( \phi \right) }+{{l}^{2}} m\\ {{l}^{2}} m \cos{\left( \phi \right) }+{{l}^{2}} m & {{l}^{2}} m\end{pmatrix}\]

The Y' matrix contains 2nd derivative terms for the state variables Theta and Phi as such.

--> Yprime: matrix(
[('diff(θ,t,2))],
[('diff(φ,t,2))]
);
\[\tag{Yprime}\begin{pmatrix}\frac{{{d}^{2}}}{d {{t}^{2}}} \theta \\ \frac{{{d}^{2}}}{d {{t}^{2}}} \phi \end{pmatrix}\]

The G matrix contains remaining terms of the differential equations of motion which do not contain 2nd derivatives of Theta and Phi; moved to the right side of the equality sign.

--> G: 1·matrix(
[g·l·m·sin(φ+θ)l^2·m·sin(φ)·('diff(φ,t,1))^22·l^2·m·('diff(θ,t,1))·sin(φ)·('diff(φ,t,1))+2·g·l·m·sin(θ)],
[g·l·m·sin(φ+θ)+l^2·m·('diff(θ,t,1))^2·sin(φ)]
);
\[\tag{G}\begin{pmatrix}-g l m \sin{\left( \phi +\theta \right) }+{{l}^{2}} m \sin{\left( \phi \right) } {{\left( \frac{d}{d t} \phi \right) }^{2}}+2 {{l}^{2}} m\, \left( \frac{d}{d t} \theta \right) \sin{\left( \phi \right) } \left( \frac{d}{d t} \phi \right) -2 g l m \sin{\left( \theta \right) }\\ -g l m \sin{\left( \phi +\theta \right) }-{{l}^{2}} m\, {{\left( \frac{d}{d t} \theta \right) }^{2}} \sin{\left( \phi \right) }\end{pmatrix}\]

The expression A*Y' = G(y,y') can be rearranged to solve for Y' by multiplying both sides by the inverse of matrix A to yield Y' = Ainv*G(y,y'). But first, matrix A can be simplified by factoring and dividing by the m*l^2 term present in each element. Note matrix G(y,y') must also be divided by the same m*l^2 term.

Factoring matrix A, dividing by m*l^2, inverting and expanding yields the following expression for Ainv.

--> Ainv:expand(invert(factor(A)/(m·l^2)));
\[\tag{Ainv}\begin{pmatrix}\frac{1}{2-{{\cos{\left( \phi \right) }}^{2}}} & -\frac{\cos{\left( \phi \right) }}{2-{{\cos{\left( \phi \right) }}^{2}}}-\frac{1}{2-{{\cos{\left( \phi \right) }}^{2}}}\\ -\frac{\cos{\left( \phi \right) }}{2-{{\cos{\left( \phi \right) }}^{2}}}-\frac{1}{2-{{\cos{\left( \phi \right) }}^{2}}} & \frac{2 \cos{\left( \phi \right) }}{2-{{\cos{\left( \phi \right) }}^{2}}}+\frac{3}{2-{{\cos{\left( \phi \right) }}^{2}}}\end{pmatrix}\]
--> factor(Ainv);
\[\tag{%o12} \begin{pmatrix}-\frac{1}{{{\cos{\left( \phi \right) }}^{2}}-2} & \frac{\cos{\left( \phi \right) }+1}{{{\cos{\left( \phi \right) }}^{2}}-2}\\ \frac{\cos{\left( \phi \right) }+1}{{{\cos{\left( \phi \right) }}^{2}}-2} & -\frac{2 \cos{\left( \phi \right) }+3}{{{\cos{\left( \phi \right) }}^{2}}-2}\end{pmatrix}\]

Note the expression for matrix Ainv can be further simplified by moving the common element denominator term outside the matrix.

Factoring matrix G and dividing by m*l^2 yields the following expression for G.

--> factor(G)/(m·l^2);
\[\tag{%o13} \begin{pmatrix}-\frac{g \sin{\left( \phi +\theta \right) }-l \sin{\left( \phi \right) } {{\left( \frac{d}{d t} \phi \right) }^{2}}-2 l\, \left( \frac{d}{d t} \theta \right) \sin{\left( \phi \right) } \left( \frac{d}{d t} \phi \right) +2 g \sin{\left( \theta \right) }}{l}\\ -\frac{g \sin{\left( \phi +\theta \right) }+l\, {{\left( \frac{d}{d t} \theta \right) }^{2}} \sin{\left( \phi \right) }}{l}\end{pmatrix}\]

The above expressions for matrix Ainv and G are implemented for the non-linearized differential equations of motion in the dotS function of the PyODE double pendulum simulation modeled in the tutorial2x.py Python script.


Created with wxMaxima.