File:Pendulum rel error.svg

Summary

Description
English: Relative error in the approximation of the period of oscillation of a pendulum using a power series. The error is a function of the initial angle, for small angles the period does not depend on it.
Español: Error relativo en la aproximación del período de oscilación de un péndulo usando una serie de potencias. El error es una función del ángulo inicial, para ángulos pequeños el período no depende de este parámetro.
Date
Source Own work
Author Nicoguaro
SVG development
InfoField
Source code
InfoField

Python code

from __future__ import division
from scipy.special import ellipk, factorial
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams

rcParams['font.size'] = 16
palette= ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33"]

def period(angle):
    return 4*ellipk(np.sin(angle/2)**2)

def approx_period(angle, num):
    return 2*np.pi*sum((factorial(2*n)/(2**n * factorial(n))**2)**2
                       * np.sin(angle/2)**(2*n) for n in range(0, num + 1))

theta = np.linspace(0, np.pi/2, 100)
for num in range(0, 6):
    rel_error = np.abs(approx_period(theta, num) - period(theta))/period(theta)
    plt.plot(theta*180/np.pi, 100*rel_error,
             label=r"$T_{%i}$"%(2*num), lw=2, color=palette[num])
plt.xlabel(r"Initial angle (degrees): $\theta_0$ ")
plt.ylabel(r"Relative Error (%): $\left\Vert\frac{T - T_k}{T}\right\Vert \times 100$")
plt.ylim(0, 1)
plt.grid(ls="--", alpha=0.4)
plt.legend(loc="best", fontsize=14, framealpha=0.8)
plt.savefig("Pendulum_rel_error.svg", bbox_inches="tight")
plt.show()

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
Category:CC-BY-4.0#Pendulum%20rel%20error.svgCategory:Self-published work
Category:Diagrams of pendulums Category:Elliptic functions Category:Approximation
Category:Approximation Category:CC-BY-4.0 Category:Diagrams of pendulums Category:Elliptic functions Category:Self-published work Category:Valid SVG created with Matplotlib code