Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

odeint

Integrates first-order ordinary differential-equation systems from an initial state over specified time points. It supports stiff and non-stiff systems and can pass extra arguments or solver/Jacobian options.

How it works

odeint advances an initial-value problem for a first-order ODE across the supplied time points. The derivative callback normally receives the current state before time, while tfirst=True switches it to time before state; extra model arguments are passed through args.

Syntax

scipy.integrate.odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0, ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0, hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12, mxords=5, printmessg=0, tfirst=False)

Parameters

NameTypeDescription
funccallableDerivative function defining the system; by default it is called as func(y, t, ...), or as func(t, y, ...) when tfirst=True.
y0array_likeInitial condition for the state.
tarray_likeSequence of time points at which to compute the solution.
argstuple, optionalTuple of extra arguments passed to func.
Dfuncallable, optionalCallable returning the Jacobian of func with respect to y.
col_derivbool, optionalWhether derivatives in Dfun are arranged down columns.
full_outputbool, optionalWhether to return the solver's diagnostic information.
ml, muint, optionalLower and upper Jacobian bandwidths for banded systems.
rtol, atolarray_like or float, optionalRelative and absolute error tolerances.
tcritarray_like, optionalCritical points that must not be crossed.
h0, hmax, hminfloat, optionalInitial, maximum, and minimum integration step sizes.
ixpr, mxstep, mxhnil, mxordn, mxords, printmessgint or bool, optionalControls diagnostic printing and limits on steps, warnings, and method orders.

Returns

A solution array with one row for each requested time point; when full_output is true, diagnostic information is returned as well.

Key points

  • odeint integrates a system of ordinary differential equations from an initial state.
  • It handles first-order initial-value systems whether they are stiff or non-stiff.
  • The state y may contain multiple coupled variables, so the function supports vector-valued systems.
  • The t argument specifies the time points at which the solution is returned.
  • Use args to pass fixed parameters from the integration call into the derivative function.

Example: Integrate exponential decay

import numpy as np
from scipy.integrate import odeint

def decay(y, t, rate):
    return -rate * y

t = np.linspace(0, 5, 51)
solution = odeint(decay, y0=1.0, t=t, args=(0.5,))
print(solution[-1, 0])

Integrates exponential decay from an initial value of 1 over the requested time points.

When to use it

Scalar initial-value models

Simulate a scalar decay, growth, or other time-dependent process from a known initial value.

Coupled dynamical systems

Evolve several interacting quantities whose derivatives depend on the full state vector.

Structured stiff systems

Provide a Jacobian and band structure when the model has exploitable derivative structure.

Interview questions

QWhat problem does odeint solve?

odeint solves an initial-value problem for a first-order system, using the supplied initial state and requested time points. It supports both stiff and non-stiff systems.

Follow-up: How can the callback argument order be changed? Set tfirst=True so the callback receives time before state; otherwise the default order is state before time.

QWhat are the three core inputs?

func is the derivative callback, y0 is the initial state, and t contains the time points where the solution is requested. Additional constants for func are supplied through args.

Follow-up: What must the callback return? It must return the derivative of the current state, with dimensions compatible with y0.

QHow can solver derivatives and diagnostics be provided?

Dfun supplies the Jacobian of the derivative with respect to the state. col_deriv controls whether that Jacobian is arranged with derivatives down columns, and full_output requests diagnostic information.

Follow-up: When are ml and mu useful? They describe lower and upper Jacobian bandwidths for banded systems, allowing the solver to exploit that structure.

  • scipy.integrate.solve_ivp
  • scipy.integrate.ode
  • scipy.integrate.quad

Source: odeint — SciPy v1.18.0 Manual. Checked 2026-10-15.