fsolve(func, x0, args=(), fprime=None, full_output=0, col_deriv=0, xtol=1.49012e-08, maxfev=0, band=None, epsfcn=None, factor=100, diag=None)
Return the roots of the (non-linear) equations defined by func(x) = 0
given a starting estimate.
fsolve
is a wrapper around MINPACK's hybrd and hybrj algorithms.
A function that takes at least one (possibly vector) argument, and returns a value of the same length.
The starting estimate for the roots of func(x) = 0
.
Any extra arguments to :None:None:`func`
.
A function to compute the Jacobian of :None:None:`func`
with derivatives across the rows. By default, the Jacobian will be estimated.
If True, return optional outputs.
Specify whether the Jacobian function computes derivatives down the columns (faster, because there is no transpose operation).
The calculation will terminate if the relative error between two consecutive iterates is at most :None:None:`xtol`
.
The maximum number of calls to the function. If zero, then 100*(N+1)
is the maximum where N is the number of elements in :None:None:`x0`
.
If set to a two-sequence containing the number of sub- and super-diagonals within the band of the Jacobi matrix, the Jacobi matrix is considered banded (only for fprime=None
).
A suitable step length for the forward-difference approximation of the Jacobian (for fprime=None
). If :None:None:`epsfcn`
is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.
A parameter determining the initial step bound ( factor * || diag * x||
). Should be in the interval (0.1, 100)
.
N positive entries that serve as a scale factors for the variables.
The solution (or the result of the last iteration for an unsuccessful call).
A dictionary of optional outputs with the keys:
nfev
number of function calls
njev
number of Jacobian calls
fvec
function evaluated at the output
fjac
the orthogonal matrix, q, produced by the QR factorization of the final approximate Jacobian matrix, stored column wise
r
upper triangular matrix produced by QR factorization of the same matrix
qtf
the vector (transpose(q) * fvec)
An integer flag. Set to 1 if a solution was found, otherwise refer to :None:None:`mesg`
for more information.
If no solution is found, :None:None:`mesg`
details the cause of failure.
Find the roots of a function.
root
Interface to root finding algorithms for multivariate functions. See the method=='hybr'
in particular.
Find a solution to the system of equations: x0*cos(x1) = 4, x1*x0 - x1 = 5
.
>>> from scipy.optimize import fsolve
... def func(x):
... return [x[0] * np.cos(x[1]) - 4,
... x[1] * x[0] - x[1] - 5]
... root = fsolve(func, [1, 1])
... root array([6.50409711, 0.90841421])
>>> np.isclose(func(root), [0.0, 0.0]) # func(root) should be almost 0.0. array([ True, True])See :
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.optimize._minpack_py.fsolve
scipy.optimize._zeros_py.bisect
scipy.optimize._zeros_py.toms748
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