Python - Differential Equation - ODE 007 UiA Logo

[Main Menu][Prev][Next]
ODE 001 - Code


We have the ordinary differential equation:
y'' + 2y' + 2y = cos(2x)      y(0) = 0   y'(0) = 0

To the left you see the code for a Python program solving this differential equation numerically and drawing the graph.

The function odeint from the library scipy.integrate solve this differential equation.
odeint has three parameters:
model : function call where you have the mathematical model in the diff.eq.
y0    : initial value [y(0)=0, y'(0)=0]
t     : time array
The two first parameters (model and y0) are transferred to the first parameter y in the model function.
The body part (line 19-34) of model contains the mathematical model of the diff.eq.

ODE 001 - Graph



MatRIC Logo