{ } Raw JSON

bundles / scipy 1.17.1 / scipy / integrate / _ivp / common / num_jac

function

scipy.integrate._ivp.common:num_jac

source: /scipy/integrate/_ivp/common.py :268

Signature

def   num_jac ( fun t y f threshold factor sparsity = None )

Summary

Finite differences Jacobian approximation tailored for ODE solvers.

Extended Summary

This function computes finite difference approximation to the Jacobian matrix of fun with respect to y using forward differences. The Jacobian matrix has shape (n, n) and its element (i, j) is equal to d f_i / d y_j.

A special feature of this function is the ability to correct the step size from iteration to iteration. The main idea is to keep the finite difference significantly separated from its round-off error which approximately equals EPS * np.abs(f). It reduces a possibility of a huge error and assures that the estimated derivative are reasonably close to the true values (i.e., the finite difference approximation is at least qualitatively reflects the structure of the true Jacobian).

Parameters

fun : callable

Right-hand side of the system implemented in a vectorized fashion.

t : float

Current time.

y : ndarray, shape (n,)

Current state.

f : ndarray, shape (n,)

Value of the right hand side at (t, y).

threshold : float

Threshold for y value used for computing the step size as factor * np.maximum(np.abs(y), threshold). Typically, the value of absolute tolerance (atol) for a solver should be passed as threshold.

factor : ndarray with shape (n,) or None

Factor to use for computing the step size. Pass None for the very evaluation, then use the value returned from this function.

sparsity : tuple (structure, groups) or None

Sparsity structure of the Jacobian, structure must be csc_matrix.

Returns

J : ndarray or csc_matrix, shape (n, n)

Jacobian matrix.

factor : ndarray, shape (n,)

Suggested factor for the next evaluation.

Aliases

  • scipy.integrate._ivp.bdf.num_jac