1.2. ODE module

ODE.euler(f, initial, interval, h)

This function solves the differential equation using Euler’s method and initial value condition.

Parameters
  • f (function) – function form of the differential equation to be solved

  • initial (tuple) – tuple of the initial values

  • interval (tuple) – tuple of the interval in which the differential eq

  • h (float) – step size for each iteration

Returns

  • ts (1d array) – array of t’s

  • ys (1d array) – array of corresponding y’s

ODE.heun(f, initial, interval, h)

This function solves the differential equation using Heun’s method and initial value condition.

Parameters
  • f (function) – function form of the differential equation to be solved

  • initial (tuple) – tuple of the initial values

  • interval (tuple) – tuple of the interval in which the differential eq

  • h (float) – step size for each iteration

Returns

  • ts (1d array) – array of t’s

  • ys (1d array) – array of corresponding y’s

ODE.midpoint_euler(f, initial, interval, h)

This function solves the differential equation using Ralstone’s method and initial value condition.

Parameters
  • f (function) – function form of the differential equation to be solved

  • initial (tuple) – tuple of the initial values

  • interval (tuple) – tuple of the interval in which the differential eq

  • h (float) – step size for each iteration

Returns

  • ts (1d array) – array of t’s

  • ys (1d array) – array of corresponding y’s

ODE.ralstone(f, initial, interval, h)

This function solves the differential equation using Ralstone’s method and initial value condition.

Parameters
  • f (function) – function form of the differential equation to be solved

  • initial (tuple) – tuple of the initial values

  • interval (tuple) – tuple of the interval in which the differential eq

  • h (float) – step size for each iteration

Returns

  • ts (1d array) – array of t’s

  • ys (1d array) – array of corresponding y’s

ODE.rk3(f, initial, interval, h)

This function solves the differential equation using 3rd order Runga-Kutta method and initial value condition.

Parameters
  • f (function) – function form of the differential equation to be solved

  • initial (tuple) – tuple of the initial values

  • interval (tuple) – tuple of the interval in which the differential eq

  • h (float) – step size for each iteration

Returns

  • ts (1d array) – array of t’s

  • ys (1d array) – array of corresponding y’s

ODE.rk4(f, initial, interval, h)

This function solves the differential equation using 4th order Runga-Kutta method and initial value condition.

Parameters
  • f (function) – function form of the differential equation to be solved

  • initial (tuple) – tuple of the initial values

  • interval (tuple) – tuple of the interval in which the differential eq

  • h (float) – step size for each iteration

Returns

  • ts (1d array) – array of t’s

  • ys (1d array) – array of corresponding y’s