Euler’s method
Use Euler’s method to solve the differential equation
dxdt=−x3+sint
with the initial condition x=0 at t=0.
Plot x(t) up to t=100, using 1000 steps.
Euler’s method II
Use Euler’s method to solve the differential equation
dydx=cos(x)sin(y)+cos(y)
with the initial condition x=1 at t=0.
Plot x(t) up to t=100, using 1000 steps.
Second order Runge-Kutta method
Use a second order Runge-Kutta method to solve the differential equation
dxdt=−x3+sint
with the initial condition x=0 at t=0.
Plot x(t) up to t=100, using 1000 steps. Investigate convergence with respect to the number of steps, and compare this to the performance of Euler’s method.
Modelling a non-linear pendulum
In The strange attractor tutorial we use Euler’s method to solve simultaneous first order ODEs. At the end of the tutorial you are also shown how to re-cast the second order ODE for a non-linear pendulum as two simultaneous first order ODEs. Using expressions 11 and 12 on the tutorial page, and following the same method outlined as that outlined for the Strange Attractor, write a piece of code for modelling θ as a function of time.
Tip: Combine the two variable θ and ω into a single vector r=(θ,ω). The method will give us a value for θ and ω, but we can ignore the ω values generated if they are not needed.
Back to Modelling with Ordinary Differential Equations.