Qu

fsolve

Builtin index · Signal processing

result = fsolve(f, x0, [tol=1e-10], [max_iter=200], [jac=])

Input: f, x0, tol, max_iter, jac · Output: result

What it is

Solves the nonlinear system f(x) = 0. f: a function (or the string naming a user-defined function) taking a vector x and returning a real vector; x0: the starting vector; tol (number): the stopping tolerance; max_iter (positive whole number): the iteration cap (each trial step counts as one, and an iteration costs at most length(x0) + 7 calls of f, so a slow f cannot run unbounded); jac (optional function or name): returns the Jacobian as a matrix with one row per equation and one column per unknown, otherwise a forward-difference Jacobian is used. Method: damped Newton (a backtracking line search on norm(f)) with Levenberg-Marquardt as the fallback whenever the Newton step cannot reduce the residual, which is robust far from the root and quadratically convergent near it. A non-square system is solved in the least-squares sense (more equations than unknowns) or returns a point on the solution set (fewer).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = fsolve(f, x0, [tol=1e-10], [max_iter=200], [jac=])
f string or vectorf: a function (or the string naming a user-defined function) taking a vector x and returning a real vector.
x0 vectorx0: the starting vector.
tol number, optional (default 1e-10)tol (number): the stopping tolerance.
max_iter number, optional (default 200)max_iter (positive whole number): the iteration cap (each trial step counts as one, and an iteration costs at most length(x0) + 7 calls of f, so a slow f cannot run unbounded).
jac matrix, optionaljac (optional function or name): returns the Jacobian as a matrix with one row per equation and one column per unknown, otherwise a forward-difference Jacobian is used.
Model —kind "fsolve"
x vectorthe solution vector
fval —f at x
norm —the 2-norm of fval
iterations numbera number
converged booleana boolean
jac —passed through
Returns a Model (kind "fsolve") with x (the solution vector), fval (f at x), norm (the 2-norm of fval), iterations (a number) and converged (a boolean). converged means norm <= tol * max(1, norm(f(x0))), or for more equations than unknowns that the residual is orthogonal to the Jacobian's columns (a least-squares minimum). Failing to converge is not an error: check converged; a system with no real root such as x^2 + 1 = 0 returns the nearest point with converged = false. Errors: an unknown function, a non-finite x0, f(x0) that is NaN or Inf, an f that returns a different number of values on different calls, a jac of the wrong shape, and any error raised inside f or jac (passed through).

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.