Suppose the callable has signature f0(x,*my_args,**my_kwargs), where
my_args and my_kwargs are required positional and keyword arguments.
Rather than passing f0 as the callable, wrap it to accept
only x; e.g., pass fun=lambdax:f0(x,*my_args,**my_kwargs) as the
callable, where my_args (tuple) and my_kwargs (dict) have been
gathered before invoking this function.
x0ndarray
Initial guess.
argstuple, optional
Extra arguments passed to the objective function and its Jacobian.
If jac is a Boolean and is True, fun is assumed to return the
value of Jacobian along with the objective function. If False, the
Jacobian will be estimated numerically.
jac can also be a callable returning the Jacobian of fun. In
this case, it must accept the same arguments as fun.
tolfloat, optional
Tolerance for termination. For detailed control, use solver-specific
options.
callbackfunction, optional
Optional callback function. It is called on every iteration as
callback(x,f) where x is the current solution and f
the corresponding residual. For all methods but ‘hybr’ and ‘lm’.
optionsdict, optional
A dictionary of solver options. E.g., xtol or maxiter, see
show_options() for details.
Returns:
solOptimizeResult
The solution represented as a OptimizeResult object.
Important attributes are: x the solution array, success a
Boolean flag indicating if the algorithm exited successfully and
message which describes the cause of the termination. See
OptimizeResult for a description of other attributes.
This section describes the available solvers that can be selected by the
‘method’ parameter. The default method is hybr.
Method hybr uses a modification of the Powell hybrid method as
implemented in MINPACK [1].
Method lm solves the system of nonlinear equations in a least squares
sense using a modification of the Levenberg-Marquardt algorithm as
implemented in MINPACK [1].
Method df-sane is a derivative-free spectral method. [3]
Methods broyden1, broyden2, anderson, linearmixing,
diagbroyden, excitingmixing, krylov are inexact Newton methods,
with backtracking or full line searches [2]. Each method corresponds
to a particular Jacobian approximations.
Method broyden1 uses Broyden’s first Jacobian approximation, it is
known as Broyden’s good method.
Method broyden2 uses Broyden’s second Jacobian approximation, it
is known as Broyden’s bad method.
Method anderson uses (extended) Anderson mixing.
Method Krylov uses Krylov approximation for inverse Jacobian. It
is suitable for large-scale problem.
Method linearmixing uses a scalar Jacobian approximation.
Method excitingmixing uses a tuned diagonal Jacobian
approximation.
Warning
The algorithms implemented for methods diagbroyden,
linearmixing and excitingmixing may be useful for specific
problems, but whether they will work may depend strongly on the
problem.