Exploring Non-linear Dynamics: Constructing the Bifurcation Diagram
of a Damped Driven Pendulum using Python
JOAN JANI
Department of Engineering Physics,
Polytechnic University of Tirana,
Rr. S. Delvina, 1001,
ALBANIA
Abstract: In this paper, we present a detailed analysis and construction of the bifurcation diagram for the
damped-driven pendulum system. The bifurcation diagram in general presents the qualitative changes of the
steady-state behavior for the pendulum. For this purpose, we implement the use of the Python programming
language with the inclusion of scientific libraries. This nonlinear dynamical system is an example of a system that
exhibits a chaotic regime, which is the sensitivity of its behavior to the initial conditions and the parameters of the
system. We investigate the response of the system to a range of drive strengths γapplied. By changing the driving
strength, the system reveals patterns of periodicity, quasi-periodic, and chaotic regimes. The critical values where
it goes from regular motion to chaotic one are highlighted, offering further understanding of the mechanisms of the
transitions. This study presents the use of the Python programming language for the modeling and visualization
of non-dynamic systems and contributes to a deeper understanding of nonlinear oscillator dynamics.
Key-Words: - Bifurcation Diagram, Damped Driven Pendulum, Non-linear Dynamics, Python Programming,
Numerical Methods, Chaotic Systems, Periodicity.
Received: March 19, 2024. Revised: August 11, 2024. Accepted: September 12, 2024. Published: October 24, 2024.
1 Introduction
In complex systems, the state of apparently
stochastic and unpredictable behavior derived from a
deterministic description of them is called chaos. This
concept defines the limits of order and predictability,
[1]. Its presence is ubiquitous, from turbulence in
weather systems to the behavior of electronic circuits,
[2]. This behavior generally comes from nonlinear
systems under certain conditions; this means that
not all nonlinear systems are chaotic, [3]. During a
chaotic regime, the behavior of the system becomes
unpredictable, giving the impression of stochastic
and random operation, [4].
The bifurcation diagram is a powerful tool for
understanding the evolution of a complex system by
changing a parameter of them, [5]. The bifurcation
diagram plots the possible steady state values of the
system against a varying parameter, [6]. This diagram
starts with a stable state, and as the parameters
change, these states branch into multiple branches;
this is an indication of different behaviors. The points
where the graph is splitting are known as bifurcation
points, [7].
The logistic map is an example of a bifurcation
diagram in which the parameter of the growth rate
increases. In this diagram, the population can first
stabilize in a value, then oscillate between two values
and eventually become chaotic, [8]. The stability
and periodicity within the system reveal the intricate
transition to chaos. This reveals the delicate interplay
between order and disorder in natural phenomena, [9].
The use of advanced computational tools for
modeling, data analysis, and visualization of the
results in the fields of dynamical systems creates new
opportunities for research, [10]. The widespread use
of Python as a tool for studying dynamical systems
has been well established during recent years. There
are numerous examples presented in literature for the
application of Python in studying dynamical systems,
[11], [12], [13]. The potential use of chaotic systems
for cryptography purposes and their use in secure
communication systems in general has increased the
interest in their study, [14].
In this paper, we investigate the dynamics of the
non-linear dumped-driven pendulum and explore the
construction of bifurcation diagrams using Python
programming. Several analytical solutions exist in
the literature for the damped pendulum, but when
an external force is applied, the solution is typically
only approximated numerically, [15], [16]. The
proposed method is efficient and easy to implement in
other chaotic systems. Another advantage is that our
proposal is based on free source code, available in the
public domain, and the program used and described
in this paper.
WSEAS TRANSACTIONS on SYSTEMS
DOI: 10.37394/23202.2024.23.27
Joan Jani
E-ISSN: 2224-2678
243
Volume 23, 2024
2 Problem Formulation
We present a new approach to constructing the
bifurcation diagram in a dynamic system. We have
chosen Python as the programming language for this
purpose. We will use it to model the system, simulate
it, and present the results.
A nonlinear damped pendulum is an extension of
the simple pendulum that incorporates both damping
effects and nonlinearity in its restoring force. This
system is governed by a differential equation that
accounts for the pendulum’s angle, damping, and
nonlinear restoring forces, [6]. Such pendulums are
found in various natural and engineered systems,
and their study provides insight into the dynamics
of oscillatory systems with energy dissipation and
nonlinearities.
Fig. 1: A simple pendulum where three forces are
applied, the weight, the resistive force and the driven
force, [6]
The equation describing the motion of the
pendulum can be derived from the equation of a rigid
object under a net torque I¨
θ= Γ, where Idenotes the
moment of inertia of the object in our case I=mL2,
and Γis the net torque about the pivot point. Figure
(1) shows three forces applied on the object: the
weight of the object mg applies a torque mgL sin θ,
the resistive force is proportional to the speed of the
object and has a magnitude bv, hence exerts a torque
Lbv =bL2˙
θand the driving force F(t)applying
a torque LF (t). Thus, the equation of motion:
mL2¨
θ=mgL sin θbL2˙
θ+LF (t)(1)
The drive external force F(t)is sinusoidal given by:
F(t) = Acos(ωDt)
where Ais the amplitude of the driving force (in
Newtons) and ωDis the drive frequency. Rearranging
the equation (1) we have and substituting the
expression for the external force we have:
¨
θ+g
Lsin θ+b
m˙
θ=A
mL cos ωDt(2)
By substituting the coefficient b/m= 2βwhere β
is called the damping constant, g/L=ω2
owhere
ωodenotes the natural frequency of the pendulum
and A
mL =γω2
owhere γdenotes the drive strength,
we have the differential equation of the motion for a
driven damped pendulum:
¨
θ+ω2
osin θ+ 2β˙
θ=γω2
ocos ωt (3)
When the dimensionless parameter γis less than
1, it indicates that the driving force is weaker than the
pendulum’s weight. In this case, the motion induced
by the driving force is relatively small compared
to the overall dynamics governed by gravity and
damping, [6]. We investigate the motion of the
pendulum by varying the parameter γacross a range
of values.
3 Solution
We will use numerical methods to solve the equation
presented in (3). Numerical methods have been made
easier through their implementation in packages such
as Scipy in the Python programming language, [17].
The results from the simulation will be presented
using the matplotlib package, [18]. These tools are
easy to use and do not require a lot of computing
power. The parameters of the system are chosen
ωD= 2π,ωo= 1.5ωand β=ωo/4.
The second-order differential equation (3) is
rewritten as a system of two second-order equations
as follows:
dt =ω2
osin θ2β˙
θ+γω2
ocos ωDt
dt =ω
(4)
The system of differential equations can be solved
through the function odeint, which is in the scipy
package of the Python ecosystem. The function
odeint is using lsoda from the FORTRAN library
odepack. For solving the equations we use γ= 0.9,
we use the initial conditions ˙
θ= 0 and several
values for the initial angle listed bellow, θ0=
[2.5,1.5,0.5,0.5,0,1.5,2.5]. The solutions for
every initial angle value are plotted together and
presented in Fig. 2.
The first we notice in Fig. 2 is that the system,
after a transition state which depends on the initial
conditions, ends up in a steady state which does not
depend on the initial conditions. For a linear damped
oscillator subjected to a sinusoidal driving force,
there is a unique attractor that the system’s motion
will approach regardless of the initial conditions.
Moreover, the motion of the attractor is sinusoidal
and has a frequency that precisely corresponds to the
drive frequency. As can be seen here, the period of
WSEAS TRANSACTIONS on SYSTEMS
DOI: 10.37394/23202.2024.23.27
Joan Jani
E-ISSN: 2224-2678
244
Volume 23, 2024
Fig. 2: The angle θof the pendulum as a
function of time for various initial conditions θ0=
[2.5,1.5,0.5,0.5,0,1.5,2.5] when γ= 0.09
the motion is T= 1s, which is equal to the period
of the external force. So, in the linear regime, the
system obeys the frequency of the external force.
This behaviour is thoroughly analyzed in, [19]. This
will continue to happen as the value for γremains
sufficiently small. For some value of drive strength
γ, the attractor becomes unstable, and the system’s
behaviour becomes more complex.
Fig. 3: The angle θof the pendulum with time for two
different initial conditions with θ= 0 and θ= 0.001,
when drive strength = 1.5.
In Fig. 3, the angle θis presented as a function of
time when the value of = 1.503, two different initial
conditions θ= 0 and θ= 0.001. As can be seen from
the graph, at the beginning, the system’s behaviour
is the same for both initial conditions, but then their
difference begins to increase exponentially. The
Lyapunov exponent measures the rate of separation,
[20]. For a nonlinear oscillator, different initial
conditions can result in distinct attractors. Here, the
behaviour is not periodic as in Fig. 2, and the slight
difference in initial conditions leads the system to
different trajectories.
Οne way to show the correlation between the
parameter γand the transition of the system to chaos
is the bifurcation diagram, [6]. The construction of
this diagram is presented in detail in the following
paragraph.
4 Bifurcation
A bifurcation diagram presents the evolution of the
motion of θ(t)as the driving strength γchanges.
Our chosen values in this study are 1.03 γ
2.15. A large number of values of γevenly
spaced, by an interval of γ= 0.0001 could be
taken using the numpy function arange as follows:
numpy.arange(1.03,2.15,1e-5). By executing
this command, we get a matrix of 112000 elements
for the driving strength γ. Continuing our analysis,
we are solving the equations describing the system’s
behaviour (4) for each value of γpresented in
the matrix, with the same parameters and initial
conditions given in the previous paragraph.
The time for simulation is from 0 to 500 seconds;
the initial conditions are θ=π/2 and ˙
θ= 0.
We choose the last 100 seconds to sample the angle
θthat the oscillator is at. Sampling is done at the
same frequency as the frequency of the external force
ωD= 2π, so Ts= 1s. The calculated values of θ
for each of the values of γare stored in the matrix
biff, and are presented in Fig. 4. The time needed
to run the code is approximately 5 hours on a laptop.
The code is publicly available and can be found here,
[21].
When the system has periodic behaviour,
sampling at times equal to its period will give
us the same value. So, only one value will appear
for a given value of γin the bifurcation diagram.
This occurs for small values of γfrom γ= 1.03
to γ= 1.06631. After the value γ= 1.06631, the
system displays two points for each value of γ. This
is referred to in the literature as bifurcation, and the
system has doubled its period. The period doubles
again for γ= 1.07951, where we can get four
different points for θ. The next bifurcation occurs
when γ= 1.08268. In more detail, our plot shows
the transition to chaos than the work done before,
[22].
For constructing the bifurcation diagram, we do
not require the pendulum’s motion to be limited in
space. We aim to study when the system goes
into chaotic behaviour for a more extensive range of
values πθπof the parameter g. We believe
that changing the angle’s values affects the emergence
WSEAS TRANSACTIONS on SYSTEMS
DOI: 10.37394/23202.2024.23.27
Joan Jani
E-ISSN: 2224-2678
245
Volume 23, 2024
Fig. 4: Bifurcation diagram for 1.06 γ1.09. The
period-doubling occurs for value γequal to 1.06631,
1.07935, 1.08207 and 1.08268.
Fig. 5: Bifurcation diagram for 1.03 γ1.53.
of the system’s behaviour and, in general, its chaotic
operation.
In Fig. 5, the bifurcation diagram is present for
a wide range of values of the parameter g where
1.03 γ1.53. For 1.26 γ1.45 we
have a long stretch of period 1, followed by another
period-doubling cascade and the final section which
is primarily chaotic. What you notice is that in this
diagram, the dynamics of the system are the same
compared to diagram 12.18 form, [6].
In Fig. 6, after the chaotic section 1.495 γ
1.55, the system exhibits periodic behaviour for the
values 1.54 γ1.68.
The Fig. 7 presents the bifurcation diagram
when drive strength 1.65 γ2.15. Here,
the chaotic behaviour is present for values 1.68
γ1.815. The system exhibits periodic behaviour
Fig. 6: Bifurcation diagram for 1.4γ1.85.
Fig. 7: Bifurcation diagram for 1.65 γ2.15.
between 1.815 γ1.865. The transition to
chaos is done with a period-doubling cascade, as seen
in Fig. 4. The chaotic regime is present for values
1.865 γ2.125. After that, the system became
again periodic.
5 Conclusion
In this study, we have created the bifurcation diagram
for the damped-driven pendulum, focusing on the
transition from periodic to chaotic behavior. The
bifurcation diagram was contracted over extended
time periods. The results give a detailed bifurcation
diagram, where the complex behavior of the system
changes between periodic and chaotic regimes as the
drive strength parameter, γ, is varied.
When the drive strength value γis low, the system
shows periodic behavior that is characterized by a
single attractor that is not affected by the initial
conditions of the system. As γincreases, a series
WSEAS TRANSACTIONS on SYSTEMS
DOI: 10.37394/23202.2024.23.27
Joan Jani
E-ISSN: 2224-2678
246
Volume 23, 2024
of period-doubling bifurcations are observed, which
are leading to the chaotic behavior. The transitions
from periodic to chaotic regimes are presented in the
bifurcation diagram, with the values of drive strength
for which this occurs. For values of γsmaller than
1.06631, the system is periodic. The first period
doubling occurs when γ= 1.07935 and the next at
γ= 1.0820. For values of γ > 1.08268, the system
enters into chaotic behavior.
The investigation of chaos generated by a
damped-driven pendulum could be considered a
case study with implications in various fields, like
chaos-based cryptography for applications in secure
communications. The investigation of conditions
where chaos emerges in this system gives us potential
for controlling chaotic systems through adjusting the
parameters precisely.
The complex dynamical systems could be
effectively analyzed with the Python programming
language and libraries like SciPy for scientific
computation and Matplotlib for visualization of
results. Our approach facilitated the exploration
of the pendulum’s dynamics and underscored the
usability of these methods and in other systems. The
code is available publicly available, and it can be
found on github, [21].
Overall, in this paper we have presented a
methodology for studying the transitions of the
system from periodic to chaotic behavior of a
nonlinear system using the bifurcation diagram.
Future work will extend this analysis to explore the
effects of additional parameters, such as changing
the damping parameter. Similar approaches could be
applied in other nonlinear dynamic systems.
References:
[1] W. Szemplinska-Stupnicka, Chaos, bifurcations
and fractals around us: a brief introduction,
vol. 47. World Scientific, 2003.
[2] M. Hanias, I. Giannis, and G. Tombras,
“Chaotic operation by a single transistor circuit
in the reverse active region,” Chaos: An
Interdisciplinary Journal of Nonlinear Science,
vol. 20, no. 1, 2010.
[3] A. A. Tsonis, Chaos: from theory to
applications. Springer Science & Business
Media, 2012.
[4] A. C. Luo and Y. Guo, “Periodic motions
to chaos in pendulum,” International Journal
of Bifurcation and Chaos, vol. 26, no. 09,
p. 1650159, 2016.
[5] H. E. Nusse, J. A. Yorke, and E. J. Kostelich,
Bifurcation Diagrams, pp. 229–268. New York,
NY: Springer US, 1994.
[6] T. T. Taylor, Mechanics: classical and quantum.
Elsevier, 2016.
[7] S. Strogatz, Nonlinear Dynamics and Chaos:
With Applications to Physics, Biology,
Chemistry, and Engineering. CRC Press,
2018.
[8] S. C. Phatak and S. S. Rao, “Logistic map: A
possible random-number generator,” Physical
review E, vol. 51, no. 4, p. 3670, 1995.
[9] E. N. Lorenz and K. Haman, “The essence of
chaos,” Pure and Applied Geophysics, vol. 147,
no. 3, pp. 598–599, 1996.
[10] G. Yakubu, P. Olejnik, and J. Awrejcewicz, “On
the modeling and simulation of variable-length
pendulum systems: a review,” Archives of
Computational Methods in Engineering, vol. 29,
no. 4, pp. 2397–2415, 2022.
[11] H. P. Langtangen and A. Logg, Solving PDEs in
python: the FEniCS tutorial I. Springer Nature,
2017.
[12] S. Lynch, Dynamical systems with applications
using python. Springer, 2018.
[13] J. Jani, “Simulation of chaotic operation of
a damped driven pendulum using python,”
WSEAS Transactions on Advances in
Engineering Education, vol. 20, pp. 1–6,
2023.
[14] N. Charalampidis, C. Volos, L. Moysis,
H. E. Nistazakis, and I. Stouboulos, “A novel
piecewise chaotic map for image encryption,” in
2022 11th International Conference on Modern
Circuits and Systems Technologies (MOCAST),
pp. 1–4, IEEE, 2022.
[15] K. Johannessen, “An analytical solution to the
equation of motion for the damped nonlinear
pendulum,” European Journal of Physics,
vol. 35, p. 035014, mar 2014.
[16] S. A. E.-T. Wedad Albalawi, Alvaro H. Salas
and A. A. A.-R. Youssef, “Approximate
analytical and numerical solutions to the
damped pendulum oscillator: Newton–raphson
and moving boundary methods,” Journal of
Taibah University for Science, vol. 15, no. 1,
pp. 479–485, 2021.
[17] P. Virtanen, R. Gommers, T. E. Oliphant,
M. Haberland, T. Reddy, D. Cournapeau,
E. Burovski, P. Peterson, W. Weckesser,
J. Bright, et al., “Scipy 1.0: fundamental
algorithms for scientific computing in python,”
WSEAS TRANSACTIONS on SYSTEMS
DOI: 10.37394/23202.2024.23.27
Joan Jani
E-ISSN: 2224-2678
247
Volume 23, 2024
Nature methods, vol. 17, no. 3, pp. 261–272,
2020.
[18] J. D. Hunter, “Matplotlib: A 2d graphics
environment,” Computing in science &
engineering, vol. 9, no. 3, pp. 90–95, 2007.
[19] K. N. Anagnostopoulos, Computational
Physics, Vol I: A Practical Introduction
to Computational Physics and Scientific
Computing. Konstantinos Anagnostopoulos,
2014.
[20] J. Jani and P. Malkaj, “Numerical calculation of
lyapunov exponents in various nonlinear chaotic
systems,” International Journal of Scientific &
Technology Research, vol. 3, no. 7, pp. 87–90,
2014.
[21] J. Jani, “Bifurcation of the damped
driven pendulum with python.” https:
//github.com/igiann/Bifurcation_DDP_
Python.git, 2024.
[22] P. Kurkarni and V. Borkar, “Oscillations
in damped driven pendulum: A chaotic
system,” International Journal of Scientific and
Innovative Mathematical Research (IJSIMR),
vol. 3, no. 10, pp. 14–27, 2015.
Contribution of Individual Authors to the
Creation of a Scientific Article (Ghostwriting
Policy)
The authors equally contributed in the present
research, at all stages from formulating the problem
to the final findings and solution.
Sources of Funding for Research Presented in a
Scientific Article or Scientific Article Itself
No funding was received for conducting this study.
Conflicts of Interest
The authors have no conflicts of interest to
declare that are relevant to the content of this
article.
Creative Commons Attribution License 4.0
(Attribution 4.0 International , CC BY 4.0)
This article is published under the terms of the
Creative Commons Attribution License 4.0
https://creativecommons.org/licenses/by/4.0/deed.en
_US
WSEAS TRANSACTIONS on SYSTEMS
DOI: 10.37394/23202.2024.23.27
Joan Jani
E-ISSN: 2224-2678
248
Volume 23, 2024