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

SciPy · Function

integrate.odeint

Integrates first-order ODE systems from an initial condition across requested time points, handling stiff and non-stiff problems. The derivative callback may use either (y, t, ...) or (t, y, ...) argument order.

How it works

odeint advances an initial state through a sequence of time points by solving a first-order ODE system. The derivative callback can receive arguments in either traditional (y, t, ...) order or, with tfirst=True, (t, y, ...); optional Jacobian, tolerance, step-control, and diagnostic settings customize the integration.

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
funccallableCallable computing the derivative; signature func(y, t, ...) or func(t, y, ...) when tfirst=True.
y0arrayInitial condition for y.
tarrayTime points at which to solve for y.
argstuple, optionalExtra arguments passed to func.
Dfuncallable, optionalJacobian of func.
col_derivbool, optionalWhether Jacobian derivatives are across rows or columns.
full_outputbool, optionalWhether to return the diagnostic infodict.
ml, muint, optionalLower and upper bandwidths of the Jacobian.
rtol, atolarray_like, optionalRelative and absolute error tolerances.
tcritarray_like, optionalCritical points where integration should not step past.
h0, hmax, hminfloat, optionalInitial, maximum, and minimum step sizes.
ixpr, mxstep, mxhnil, mxordn, mxords, printmessgint or bool, optionalDiagnostic and solver-control options.

Returns

An array containing the solution at each requested time; with full_output=True, also returns an infodict of integration diagnostics.

Key points

  • Use odeint to compute trajectories for first-order ordinary differential equation systems.
  • It is intended for both stiff and non-stiff initial-value problems.
  • Pass t as the ordered time points at which the state should be returned.
  • Use args to provide additional fixed parameters to the derivative callback.
  • Provide Dfun when supplying the derivative function's Jacobian can help the solver.

Example: Solve exponential decay

import numpy as np
from scipy.integrate import odeint

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

t = np.linspace(0, 4, 9)
solution = odeint(decay, y0=[1.0], t=t, args=(0.5,))
print(solution[:, 0])

Integrates exponential decay from the initial value 1.0 at the requested time points.

When to use it

Initial-value simulation

Simulate decay, growth, motion, or other state evolution described by first-order equations.

Mixed-regime ODE solving

Integrate systems whose numerical behavior may be stiff or non-stiff.

Jacobian-assisted integration

Supply a Jacobian and bandwidth information for structured systems.

Diagnostic analysis

Inspect solver progress and diagnostics during numerical integration.

Interview questions

QWhat problem does odeint solve?

odeint solves an initial-value problem for first-order ODE systems, including stiff and non-stiff cases. It evaluates the derivative callback at the supplied time points and returns the state at each point.

Follow-up: How can the callback use the conventional argument order? Set tfirst=True so odeint calls it as func(t, y, ...), and apply the same convention to Dfun.

QWhat are the core arguments?

func computes the derivative, y0 supplies the initial state, and t specifies the sequence of times where the solution is requested. Extra fixed inputs go through args as a tuple.

Follow-up: How would you pass two constants? Define func(y, t, a, b) and call odeint(func, y0, t, args=(a, b)).

QWhen would you provide Dfun?

Dfun supplies the Jacobian of the derivative function, while ml and mu describe lower and upper Jacobian bandwidths. These options can provide solver information for banded systems.

Follow-up: What diagnostic output is available? Use full_output=True to obtain an infodict alongside the computed solution.

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

Source: scipy.integrate.odeint. Checked 2026-10-15.