FindRoot[f,{x,x0}]
searches for a numerical root of f, starting from the point x=x0.
FindRoot[lhs==rhs,{x,x0}]
searches for a numerical solution to the equation lhs==rhs.
FindRoot[{f1,f2,…},{{x,x0},{y,y0},…}]
searches for a simultaneous numerical root of all the fi.
FindRoot[{eqn1,eqn2,…},{{x,x0},{y,y0},…}]
searches for a numerical solution to the simultaneous equations eqni.
FindRoot
FindRoot[f,{x,x0}]
searches for a numerical root of f, starting from the point x=x0.
FindRoot[lhs==rhs,{x,x0}]
searches for a numerical solution to the equation lhs==rhs.
FindRoot[{f1,f2,…},{{x,x0},{y,y0},…}]
searches for a simultaneous numerical root of all the fi.
FindRoot[{eqn1,eqn2,…},{{x,x0},{y,y0},…}]
searches for a numerical solution to the simultaneous equations eqni.
Details and Options
- If the starting point for a variable is given as a list, the values of the variable are taken to be lists with the same dimensions.
- FindRoot returns a list of replacements for x, y, … , in the same form as obtained from Solve.
- FindRoot first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically.
- FindRoot has attribute HoldAll, and effectively uses Block to localize variables.
- FindRoot[lhs==rhs,{x,x0,x1}] searches for a solution using x0 and x1 as the first two values of x, avoiding the use of derivatives.
- FindRoot[lhs==rhs,{x,xstart,xmin,xmax}] searches for a solution, stopping the search if x ever gets outside the range xmin to xmax.
- If you specify only one starting value of x, FindRoot searches for a solution using Newton methods. If you specify two starting values, FindRoot uses a variant of the secant method.
- If all equations and starting values are real, then FindRoot will search only for real roots. If any are complex, it will also search for complex roots.
- You can always tell FindRoot to search for complex roots by adding 0.I to the starting value.
- The following options can be given:
-
AccuracyGoal Automatic the accuracy sought EvaluationMonitor None expression to evaluate whenever equations are evaluated Jacobian Automatic the Jacobian of the system MaxIterations 100 maximum number of iterations to use
Automatic method to be used PrecisionGoal Automatic the precision sought StepMonitor None expression to evaluate whenever a step is taken WorkingPrecision MachinePrecision the precision to use in internal computations - The default settings for AccuracyGoal and PrecisionGoal are WorkingPrecision/2.
- The setting for AccuracyGoal specifies the number of digits of accuracy to seek in both the value of the position of the root, and the value of the function at the root.
- The setting for PrecisionGoal specifies the number of digits of precision to seek in the value of the position of the root.
- FindRoot continues until either of the goals specified by AccuracyGoal or PrecisionGoal is achieved.
- If FindRoot does not succeed in finding a solution to the accuracy you specify within MaxIterations steps, it returns the most recent approximation to a solution that it found. You can then apply FindRoot again, with this approximation as a starting point.
Examples
open all close allBasic Examples (3)
Scope (4)
Find the solution of a system of two nonlinear equations:
FindRoot[{y == Exp[x], x + y == 2}, {{x, 1}, {y, 1}}]Find a root for a three-component function of three variables:
FindRoot[{Sin[x + y], Cos[x - y], x ^ 2 + y ^ 2 - z}, {{x, 1}, {y, 0}, {z, 0}}]You can cause the search to use complex values by giving a complex starting value:
FindRoot[Zeta[z], {z, 1 / 2 + 14 I}]When the function is complex for real input, a real starting value may give a complex result:
FindRoot[(Cos[z + I] - 2)(z + 2), {z, 1}]FindRoot[(Cos[z + I] - 2)(z + 2), {z, -1}]Generalizations & Extensions (1)
Options (10)
AccuracyGoal (1)
Change tolerances for error estimates:
10 - x /. FindRoot[Sin[x - 10] - x + 10, {x, 0}]Relax error tolerances for stopping:
10 - x /. FindRoot[Sin[x - 10] - x + 10, {x, 0}, AccuracyGoal -> 4, PrecisionGoal -> 4]Make estimated relative distance to the root the main criterion for stopping:
10 - x /. FindRoot[Sin[x - 10] - x + 10, {x, 0}, AccuracyGoal -> Infinity, PrecisionGoal -> 8]DampingFactor (1)
EvaluationMonitor (1)
EvaluationMonitor can be used to keep track of function evaluations used:
{res, {evx}} = Reap[FindRoot[x ^ 2 == Exp[x], {x, 0}, EvaluationMonitor :> Sow[x]]]Show[Plot[{x ^ 2, Exp[x]}, {x, -1, 0}], ListPlot[{Transpose[{evx, evx ^ 2}], Transpose[{evx, Exp[evx]}]}]]Jacobian (1)
Specify the Jacobian for a "black-box" function:
n = 1000;
A = SparseArray[{{i_, i_} -> -2., {i_, j_} /; Abs[i - j] == 1 -> 1.}, {n, n}, 0.];
blackbox[x_ ? VectorQ] := n ^ 2 A.x + x - x ^ 3 - 1;J[x_ ? VectorQ] := Module[{d = 1 - 3 x ^ 2}, n ^ 2 A + SparseArray[{i_, i_} :> d[[i]], {n, n}]]sc = ConstantArray[0., n];
Block[{e = 0}, Timing[FindRoot[blackbox[x], {x, sc}, Jacobian -> J[x], EvaluationMonitor :> e++];e]]Without a specified Jacobian, extra evaluations are used to compute finite differences:
Block[{e = 0}, Timing[FindRoot[blackbox[x], {x, sc}, EvaluationMonitor :> e++];e]]If you just know the sparse form, specifying the sparse pattern template saves evaluations:
sp = SparseArray[{{i_, j_} /; Abs[i - j] ≤ 1 -> _}, {n, n}]Block[{e = 0}, Timing[FindRoot[blackbox[x], {x, sc}, Jacobian -> {"FiniteDifference", Sparse -> sp}, EvaluationMonitor :> e++];e]]Inspect the number of Jacobian evaluations needed by different methods:
Block[{j = 0}, FindRoot[blackbox[x], {x, sc}, Jacobian -> {J[x], EvaluationMonitor :> j++}];"Jacobian Evaluations" -> j]Block[{j = 0}, FindRoot[blackbox[x], {x, sc},
Method -> "AffineCovariantNewton", Jacobian -> {J[x], EvaluationMonitor :> j++}];"Jacobian Evaluations" -> j]MaxIterations (1)
Limit or increase the number of steps taken:
FindRoot[Exp[1 / (x ^ 2 - 1)] - 10 ^ -8, {x, .1}, MaxIterations -> 10]The default number of iterations is 100:
FindRoot[Exp[1 / (x ^ 2 - 1)], {x, .1}]Eventually the algorithm stalls out since this mollifier function has all derivatives 0 at
:
FindRoot[Exp[1 / (x ^ 2 - 1)], {x, .1}, MaxIterations -> 1000]Method (2)
Method options are also explained in Unconstrained Optimization.
Find a root for
using different methods:
f[x_] = ArcTan[1000 Cos[x]];
Plot[f[x], {x, 0, 12}, Exclusions -> None]Define a function that monitors the steps and evaluations used by FindRoot:
monitoredFindRoot[args__] := Module[{s = 0, e = 0, j = 0},
{FindRoot[args, StepMonitor :> s++, EvaluationMonitor :> e++, Jacobian -> {Automatic, EvaluationMonitor :> j++}], "Steps" -> s, "Evaluations" -> e, "Jacobian Evaluations" -> j}]The default (Newton's) method:
monitoredFindRoot[ArcTan[1000Cos[x]], {x, 1}]Brent's root-bracketing method requiring two initial conditions bracketing the root:
monitoredFindRoot[ArcTan[1000Cos[x]], {x, 1, 2}, Method -> "Brent"]Secant method, starting with two initial conditions:
monitoredFindRoot[ArcTan[1000Cos[x]], {x, 1, 2}, Method -> "Secant"]Select the affine covariant Newton method:
monitoredFindRoot[ArcTan[1000Cos[x]], {x, 1}, Method -> "AffineCovariantNewton"]PrecisionGoal (1)
Change tolerances for error estimates:
10 - x /. FindRoot[Sin[x - 10] - x + 10, {x, 0}]Relax error tolerances for stopping:
10 - x /. FindRoot[Sin[x - 10] - x + 10, {x, 0}, AccuracyGoal -> 4, PrecisionGoal -> 4]Make estimated relative distance to the root the main criterion for stopping:
10 - x /. FindRoot[Sin[x - 10] - x + 10, {x, 0}, AccuracyGoal -> Infinity, PrecisionGoal -> 8]StepMonitor (1)
Monitor when iterative steps have been taken:
f[x_, y_] = {x - 1, 10(y - Cos[2x] + 1)};{res, {stxy}} = Reap[FindRoot[f[x, y], {{x, -1}, {y, -1}}, StepMonitor :> Sow[{x, y}]]]Show the steps on a contour plot of
:
ContourPlot[f[x, y].f[x, y], {x, -1, 1}, {y, -2, 1}, Epilog -> {Red, Map[Point, stxy]}]Show steps (red) and evaluations (green). A step may require several evaluations:
{res, {exy}} = Reap[FindRoot[f[x, y], {{x, -1}, {y, -1}}, EvaluationMonitor :> Sow[{x, y}]]];ContourPlot[f[x, y].f[x, y], {x, -1, 1}, {y, -2, 1}, Epilog -> {{PointSize[0.04], Red, Map[Point, stxy]}, {Green, Map[Point, exy]}}]WorkingPrecision (1)
Find a root using 100-digit precision arithmetic:
FindRoot[Cos[x ^ 2] - x, {x, 1}, WorkingPrecision -> 100]Find the root starting with machine precision and adaptively working up to precision 100:
Block[{prec = MachinePrecision}, FindRoot[Cos[x ^ 2] - x, {x, 1.0}, WorkingPrecision -> 100, StepMonitor :> If[Precision[x] ≠ prec, prec = Precision[x];Print["Increased precision to ", prec, " at x = ", x];]]]Applications (3)
Computing Inverse Functions (1)
For an isomorphism
, the inverse
is the root of
:
inv[f_, s_] := Function[{t}, s /. FindRoot[f - t, {s, 1}]]An approximate inverse for the exponential function:
einv = inv[Exp[x], x]It is very close to the built-in Log function:
Plot[einv[x] - Log[x], {x, 0, 1}, PlotRange -> All]A "black-box" function giving the period of an oscillation:
f[a_ ? NumberQ] := Module[{p = 0}, NDSolve[{x''[t] + x[t] + x[t] ^ 3 == 0, x[0] == a, x'[0] == 0}, x, {t, ∞}, Method -> {"EventLocator", "Event" -> x[t], "EventAction" :> Throw[p = t, "StopIntegration"]}];
4p];Plot[f[a], {a, 0, 4}]finv = inv[f[a], a]Plot[finv[s], {s, 3, 6}]Solving Boundary Value Problems (2)
Solve a boundary value problem
,
using a shooting method:
x1[s_ ? NumberQ] := First[x[1] /. NDSolve[{x''[t] + x'[t] + x[t] ^ 3 == Sin[4 t], x[0] == 0, x'[0] == s}, x, {t, 0, 1}]]Plot[x1[s], {s, -10, 10}]Use points on either side of the root to give bracketing starting values:
FindRoot[x1[s], {s, -1, 0}]sol = NDSolve[{x''[t] + x'[t] + x[t] ^ 3 == Sin[4t], x[0] == 0, x'[0] == s} /. %, x, {t, 0, 1}]Plot[x[t] /. sol, {t, 0, 1}]Solve the boundary-value problem
,
with n collocation points:
n = 100;Consider as a first-order system
:
f[{u_, v_}] := {v, (1 - u - u ^ 3) / ϵ};Equations for collocation using the trapezoidal rule:
eqns = Flatten[Join[{Subscript[u, 0] == 0, Subscript[u, n] == 0}, Table[Thread[{Subscript[u, i], Subscript[v, i]} == {Subscript[u, i - 1], Subscript[v, i - 1]} + (1/2 n)(f[{Subscript[u, i - 1], Subscript[v, i - 1]}] + f[{Subscript[u, i], Subscript[v, i]}])], {i, 1, n}]]];sv = Flatten[Table[{{Subscript[u, i], 0}, {Subscript[v, i], 0}}, {i, 0, n}], 1];Find a solution for a particular value of ϵ:
froot = FindRoot[eqns /. ϵ -> 0.01, sv];
sol = Table[Subscript[u, i], {i, 0, n}] /. froot;
ListLinePlot[sol]Properties & Relations (2)
For a polynomial system of equations, NSolve finds all solutions and FindRoot finds one:
polysys = Table[Total[RandomInteger[{-9, 9}, 5]RandomChoice[{x, y, z}, 5] ^ RandomInteger[{0, 3}, 5]] == 0, {3}]FindRoot will find a single solution using an iterative method:
FindRoot[polysys, Transpose[{{x, y, z}, RandomComplex[1 + I, 3]}]]NSolve will find all solutions using a direct method:
NSolve[polysys, {x, y, z}]For equations involving parameters or exact solutions use Solve, Reduce, or FindInstance:
eq = x Exp[2x + a] + 3 == 0;Solve will return some solutions:
Solve[eq, x]Reduce will enumerate all solutions:
Reduce[eq, x]FindInstance will find particular instances:
FindInstance[eq, {x, a}, 2]Possible Issues (3)
If a function is complex, variables are allowed to have complex values:
FindRoot[Zeta[1 / 2 + I t], {t, 1}]If the function is kept real, variables are also taken to be real:
FindRoot[Abs[Zeta[1 / 2 + I t]], {t, 1}]It can be time-consuming to compute functions symbolically:
f[x_] := Nest[Sin[# + Sin[2#]]&, x, 20]FindRoot[f[x], {x, 0}]//TimingRestricting the function definition avoids symbolic evaluation:
g[x_ ? NumericQ] := Nest[Sin[# + Sin[2#]]&, x, 20]FindRoot[g[x], {x, 0}]//TimingRestricting the search domain too much can be problematic. Find the solution of a system of two nonlinear equations starting from 1/2 in the region from [0,1]:
FindRoot[{y == Exp[x], x + y == 2}, {{x, 1 / 2, 0, 1}, {y, 1 / 2, 0, 1}}]Related Guides
Related Links
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0)
Text
Wolfram Research (1988), FindRoot, Wolfram Language function, https://reference.wolfram.com/language/ref/FindRoot.html (updated 2003).
CMS
Wolfram Language. 1988. "FindRoot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/FindRoot.html.
APA
Wolfram Language. (1988). FindRoot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindRoot.html
BibTeX
@misc{reference.wolfram_2026_findroot, author="Wolfram Research", title="{FindRoot}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/FindRoot.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_findroot, organization={Wolfram Research}, title={FindRoot}, year={2003}, url={https://reference.wolfram.com/language/ref/FindRoot.html}, note=[Accessed: 13-June-2026]}