Basic physics of a (physical) pendulum. The plots of the exact solution with an arbitrarily large amplitude is inspired by this article, and Wikipedia.
For more on the pendulums, please see the “pendulum” tag . For more on the small-angle approximation, please see the “Taylor expansion” tag.
These figures are used in Ben Kilminster’s lecture notes for PHY111.
Force diagram of a pendulum to apply Newton’s second law:
Force diagram of a pendulum, breaking down the force components:
Exact solution
The curves in the figures below are created using numerical data produced by these MATLAB scripts. The data needs to be loaded via these text files to compile this part of the code. A full working setup with input files is also available from this zip file.
Closed solutions (bounded)
Comparison of exact solution of a pendulum to a sine with the same period.
Please note that the ideal solution from the small-angle approximation actually has a fixed period T_0. The dashed lines are rescales along the time axis to compare the shape of the exact solutions to cosines.
Angle θ of the pendulum versus time for several amplitudes:
Angular velocity (first derivative of the pendulum’s angle):
All curves are plotted versus t/T so the peaks coincide:
Angular velocity versus t/T so the peaks coincide:
Ratio between real and ideal period of a pendulum, T/T_0, as a function of the angular amplitude (see this Wikipedia section).
Open solutions (unbounded)

Derivation of the exact solution
Mathematical derivation of the exact solution of the pendulum with Jacobi elliptic functions (closed):
Mathematical derivation of the exact solution of the pendulum (open):
Full code
Edit and compile the full code below if you like. Note that part of the code has been disabled, because it needs to load data from external text files, which cannot be run on this website. See below for the full setup.
% Author: Izaak Neutelings (October 2020)% Instructions: To compile, include data files from% https://github.com/IzaakWN/CodeSnippets/tree/master/LaTeX/TikZ/physics/dynamics_pendulum% Other sources:% https://www.scielo.br/scielo.php?script=sci_arttext&pid=S1806-11172007000400024% https://www.researchgate.net/publication/262746594_Exact_solution_for_the_nonlinear_pendulum% https://tex.stackexchange.com/questions/545590/phase-portrait-of-van-der-pol-oscillator-with-pgfplots% http://matlab.cheme.cmu.edu/2011/08/09/phase-portraits-of-a-system-of-odes/\documentclass[border=3pt,tikz]{standalone}\usepackage{physics}\usepackage{siunitx}\sisetup{detect-all} % to allow \pi in \SI\usepackage{tikz,pgfplots}\usepackage[outline]{contour} % glow around text\usetikzlibrary{calc}\usetikzlibrary{angles,quotes} % for pic\usetikzlibrary{arrows.meta}\tikzset{>=latex} % for LaTeX arrow head\contourlength{1.2pt}\colorlet{xcol}{blue!70!black}\colorlet{vcol}{green!60!black}\colorlet{myred}{red!70!black}\colorlet{myblue}{blue!70!black}\colorlet{mygreen}{green!70!black}\colorlet{mydarkred}{myred!70!black}\colorlet{mydarkblue}{myblue!60!black}\colorlet{mydarkgreen}{mygreen!60!black}\colorlet{acol}{red!50!blue!80!black!80}\tikzstyle{CM}=[red!40!black,fill=red!80!black!80]\tikzstyle{xline}=[xcol,thick,smooth]\tikzstyle{mass}=[line width=0.6,red!30!black,fill=red!40!black!10,rounded corners=1,top color=red!40!black!20,bottom color=red!40!black!10,shading angle=20]\tikzstyle{faded mass}=[dashed,line width=0.1,red!30!black!40,fill=red!40!black!10,rounded corners=1,top color=red!40!black!10,bottom color=red!40!black!10,shading angle=20]\tikzstyle{rope}=[brown!70!black,very thick,line cap=round]\def\rope#1{ \draw[black,line width=1.4] #1; \draw[rope,line width=1.1] #1; }\tikzstyle{force}=[->,myred,very thick,line cap=round]\tikzstyle{velocity}=[->,vcol,very thick,line cap=round]\tikzstyle{Fproj}=[force,myred!40]\tikzstyle{myarr}=[-{Latex[length=3,width=2]},thin]
Click to download: dynamics_pendulum.zip (including input txt files) • dynamics_pendulum.tex • dynamics_pendulum.pdf
Open in Overleaf: dynamics_pendulum.zip
MATLAB figures for the exact solution of a pendulum:
Closed solutions (bounded):
Open solutions (unbounded):