Comparing behaviour of linear and non-linear differential equations describing pendulum movement
by Claudio Mora Díaz​
​Pontificia Universidad Católica de Chile
Escuela de Ingeniería

Introduction

Differential equations are use to model a great variety of physical systems based on the analysis of how things change over time. Due to its nature, many differential equations are not easily solved by analytic methods, furthermore, in some cases such solution does not exist or can not be represented in terms of known mathematical expressions (such as polynomials, trigonometric functions, logarithmics, etc).
​
In this document, I will study the behaviour of a particular set of differential equations. The first one allows to be solved analytical, the second however, will need a numerical approach. These equations model the movement of a simple pendulum; a system consisting of a mass
m
swinging in a 2D space around a fixed vertical axis, attached to a massless rod (not flexible) of length
L
[1].
​
One of the simplest forms of the model considers no air resistance and no external forces being applied to the mass. It can be expressed as:
2
d
θ
d
2
t
+
g
L
sin(θ)0
(
1
)
Where
θ=θ(t)
is the counterclockwise angle that the rod makes with the vertical at time
t
, and
g
is the acceleration given by gravity. Due to the fact that there is no air resistance, nor a force being applied, the system is independent of the mass.
​
Despite all the assumptions and simplifications, the equation in (1) can be hard to solve analytical. Hence, we transform the model to be linear:
2
d
θ
dt
+
g
L
θ0
(
2
)
This approximation of
sin(θ)≈θ
comes from taking the first term in the Taylor series for
sin(θ)
and it is usually made for small values of θ. We can, in fact, test if this is a valid approximation by plotting the percent error in a small interval:
In[]:=
(*Approximationerrorfunction*)​​δ[θ_]:=Abs[(Sin[θ]-θ)/θ]*100​​(*Plottingthefunction*)​​Plot[{δ[θ],θ,Sin[θ]},{θ,0,Pi/3},​​(*Addingsomeaestheticelements*)​​PlotLabels->"Expressions",PlotLabel->Style["Percent error",14,FontFamily->"Times New Roman"]]
Out[]=
From the graphic, it is visible that θ and
sin(θ)
are similar in this interval
0,
π
3

with a small percentual error. Thus, it is expected that the behaviour of a “linear pendulum” is similar to that of a “sinusoidal pendulum”.

Creating the linear pendulum

Analytical solution

To create the pendulum, we first need to solve the differential equation to obtain the function modeling the angle between the rod and the vertical axis. ​We will obtain the solution for the linear equation by asigning specific values to different important parameters: first, we define
g
, which is easily recognized as the acceleration due to gravity, hence we say
g=9.81
m
2
s
is a good approximation.​As for the rest of parameters, that is, the length of the rod, the starting angle, and the initial velocity, we will let them expressed by arbitrary names
L,α,ω
respectively.
In[]:=
linearsol=DSolveValueθ''[t]+
9.81
L
θ[t]==0,θ'[0]==ω,θ[0]==α,θ,t
Out[]=
Function{t},1.αCos
3.13209t
L
+0.319275
L
ωSin
3.13209t
L

We will now assume specific values for the parameters, let’s say
L=6,α=π/6
and
ω=0
. With this, we can create the function for the angle given by time.
In[]:=
linearθ[t_]=linearsol[t]/.{L->6,α->Pi/6,ω->0}
Out[]=
0.+0.523599Cos[1.27867t]
Plotting this expression for the first 20 seconds:
In[]:=
Plot[linearθ[t],{t,0,20},AxesLabel->{"Time(s)",θ},PlotStyle->Lighter[Pink]]
Out[]=
Notice that the maximum amplitude for the function does not change, this is expected as there are no external forces draining energy from the system.

Graphics

We can now visualize all the elements from the system. I will start by creating the roof and the vertical axis from which the angle θ is measured.
In[]:=
roof=Graphics[{Brown,Thickness[0.01],Line[{{-5,0},{5,0}}]}];​​verticalaxis=Graphics[{Green,Dashed,Thickness[0.002],Line[{{0,10},{0,-10}}]}];​​Show[roof,verticalaxis,PlotRange->{{-5,5},{0,-10}}]
Out[]=
To properly get the pendulum (rod and mass), we will need to know its coordinates. Assuming the origin
(0,0)
is at the intersection of the roof with the vertical axis, we notice (with a bit of trigonometry) that its coordinates are given by:
X
l
(t)L·sin(θ(t))
(
3
)
Y
l
(t)-L·cos(θ(t))
(
4
)
Where
L
is the length of the rod. With this, we can look at the position of the pendulum at
t=0
.
In[]:=
linearX[t_]:=6*Sin[linearθ[t]]​​linearY[t_]:=-6*Cos[linearθ[t]]​​Print["Position of the mass at t=0: ","{",linearX[0],",",linearY[0],"}"]
Position of the mass at t=0: {3.,-5.19615}
To visualize it, we just need to create the mass, which I will show as a circle, and the rod will be shown as a line connecting the origin and the center of the mass.
In[]:=
linearpendulum[t_]=Graphics[{Blue,Thickness[0.003],Circle[{linearX[t],linearY[t]},0.35],Line[{{0,0},{linearX[t],linearY[t]}}]}];​​Show[roof,verticalaxis,linearpendulum[0],PlotRange->{{-5,5},{0,-10}}]
Out[]=
To see the full movement, we just need to animate this.
In[]:=
Animate[Show[roof,verticalaxis,linearpendulum[t],PlotRange->{{-5,5},{0,-10}}],{t,0,10},AnimationRate->2.5,SaveDefinitions->True]
Out[]=
t

Creating the sinusoidal pendulum

Numerical solution

Graphics

And we create the graphic object of the pendulum:
Animating this result

Comparison

Original problem

Finally, with both solutions obtained, we can compare different things. I will start taking a look at the function obtained that models the angle θ. Plotting said function for both approaches at the same time:
As expected, the two solutions differ from each other. The linear approach seems to be having a slightly faster period which results in its plot being more horizontally compressed.
​
We can also animate both pendulums at the same time, making the difference more obvious to the eye:
To see how much the result varies we can use the same technique of the percent error (assuming the numerical solution as the correct answer):
We see two important things: the first is that the maximum value of the error is increasing with each cycle of the pendulum, and that the range between the maximum and the minimum value is decreasing.

Changing the starting angle

Pendulums as graphic objects
And finally animating both pendulums:
Acquiring the same plots from the previous version:
It is clear that the behaviour of the linear approximation is completely different from the sinusoidal function. This results in an error function with more chaotic spikes.

References

1
.
Henry Edwards, Charles, E. Penney, David and Calvis, David. Differential Equations and Boundary Value Problems. 5th. s.l. : Pearson, 2019.