A simple first order ode evaluated at specific points
Posted February 27, 2013 at 02:30 PM | categories: ode | tags:
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]
Copyright (C) 2013 by John Kitchin. See the License for information about copying.