scipy 1.8.0 Pypi GitHub Homepage
Other Docs
ParametersReturns
num_jac(fun, t, y, f, threshold, factor, sparsity=None)

This function computes finite difference approximation to the Jacobian matrix of :None:None:`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, :None:None:`structure` must be csc_matrix.

Returns

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

Jacobian matrix.

factor : ndarray, shape (n,)

Suggested :None:None:`factor` for the next evaluation.

Finite differences Jacobian approximation tailored for ODE solvers.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/integrate/_ivp/common.py#248
type: <class 'function'>
Commit: