## A simple first order ode evaluated at specific points

| categories: ode | tags: | View Comments

We have integrated an ODE over a specific time span. Sometimes it is desirable to get the solution at specific points, e.g. at t = [0 0.2 0.4 0.8]; This could be desirable to compare with experimental measurements at those time points. This example demonstrates how to do that.

$$\frac{dy}{dt} = y(t)$$

The initial condition is y(0) = 1.

from scipy.integrate import odeint

y0 = 1
tspan = [0, 0.2, 0.4, 0.8]

def dydt(y, t):
return y

Y = odeint(dydt, y0, tspan)
print Y[:,0]

[ 1.          1.22140275  1.49182469  2.22554103]