To make it clearer I want to plot the solutions of the 2nd order differential equation of the damping oscillation for a pendulum. Link to wiki about the equations used : https://en.wikipedia.org/wiki/Harmonic_oscillator
from sympy.interactive import printing
printing.init_printing(use_latex=True)
import numpy as np
import scipy as sp
from sympy import*
mport sympy as syp
`from scipy.integrate import odeint
import matplotlib.pyplot as plt
t=syp.Symbol('t')
x=syp.Function('x')(t)
m=2.0
k=5.0
a=0.5
z=a/(2.0*np.sqrt(m*k))
w=np.sqrt(k/m)
eq=x.diff(t,t)+2.0*z*w*x.diff(t)+w**2.0*x
dsolve(eq,t,0,ics={eq(1.0):0,eq(2.0):5})
You're not constructing the
icsargument as intended:The answer comes out nicer (subjectively) if you don't use floats. Also I find it more natural to keep the variable
xas the functionxrather than the applied functionx(t)e.g.: