NSolve
NSolve[expr,vars]
attempts to find numerical approximations to the solutions of the system expr of equations or inequalities for the variables vars.
Details and Options


- The system expr can be any logical combination of:
-
lhs==rhs equations lhs!=rhs inequations lhs>rhs or lhs>=rhs inequalities expr∈dom domain specifications {x,y,…}∈reg region specification ForAll[x,cond,expr] universal quantifiers Exists[x,cond,expr] existential quantifiers - NSolve[{expr1,expr2,…},vars] is equivalent to NSolve[expr1&&expr2&&…,vars].
- A single variable or a list of variables can be specified.
- NSolve gives solutions in terms of rules of the form:
-
{} no solutions {{x->solx,y->soly,…},…} several solutions {{}} solution set is full dimensional - When a single variable is specified and a particular root of an equation has multiplicity greater than one, NSolve gives several copies of the corresponding solution.
- NSolve[expr,vars] assumes by default that quantities appearing algebraically in inequalities are real, while all other quantities are complex.
- In NSolve[expr,vars,Reals] all variables, parameters, constants, and function values are restricted to be real.
- NSolve[expr&&vars∈Reals,vars,Complexes] solves for real values of variables, but function values are allowed to be complex.
- NSolve[…,x∈reg,Reals] constrains x to be in the region reg. The different coordinates for x can be referred to using Indexed[x,i].
- NSolve deals primarily with linear and polynomial equations.
- The following options can be given:
-
Method Automatic what method should be used VerifySolutions Automatic whether to verify solutions WorkingPrecision Automatic precision to be used in computations - Possible Method settings include "EndomorphismMatrix" and "Homotopy".
Examples
open allclose allBasic Examples (5)
Scope (45)
Complex Equations in One Variable (8)
Univariate polynomial equations:
Polynomial equations with inexact coefficients:
Polynomial equations with multiple roots:

Univariate elementary function equations over bounded regions:
Univariate holomorphic function equations over bounded regions:
Equation with a purely imaginary period over a vertical stripe in the complex plane:
Systems of Complex Equations in Several Variables (8)
Real Equations in One Variable (11)
Polynomial equations with multiple roots:
Transcendental equations, solvable using inverse functions:
Transcendental equations, solvable using special function zeros:
Transcendental inequalities, solvable using special function zeros:
High-degree sparse polynomial equations:
Algebraic equations involving high-degree radicals:
Equations involving irrational real powers:
Tame elementary function equations:
Systems of Real Equations and Inequalities in Several Variables (9)
Quantified polynomial systems:
Transcendental systems solvable using inverse functions:
Systems exp-log in the first variable and polynomial in the other variables:
Systems elementary and bounded in the first variable and polynomial in the other variables:
Systems holomorphic and bounded in the first variable and polynomial in the other variables:


Generalizations & Extensions (1)
Options (3)
Method (1)
VerifySolutions (1)
NSolve verifies solutions obtained using non-equivalent transformations:
With VerifySolutions->False, NSolve does not verify the solutions:
Some of the solutions returned with VerifySolutions->False are not correct:
This uses a fast numeric test in an attempt to select correct solutions:
In this case the simple numeric verification gives the correct solution set:
WorkingPrecision (1)
By default, NSolve finds solutions of exact equations using machine-precision computations:
Applications (11)
Geometry (11)
Find intersection points of a circle and a parabola:
Find the intersection of InfiniteLine[{0,0},{1,1}] and InfiniteLine[{{0,1},{1,0}}]:
Find the intersections of InfiniteLine[{0,0},{1,1}] and Circle[{0,0},1]:
Find all pairwise intersections between five random lines:
Use BooleanCountingFunction to express that exactly two conditions are true:
Find the pairwise intersections of the circles Circle[{1/3 Cos[k 2π/5],1/3 Sin[k 2π/5]}] for k=0,…,4:
Find the intersection of InfiniteLine[{{-1,1,1},{1,1,1}}] and InfinitePlane[{{2,0,0},{0,2,0},{0,0,2}}]:
Find the intersections of InfiniteLine[{{-1,1,1},{1,1,1}}] and Sphere[{0,0,0},3]:
Find the intersections of InfiniteLine[{{-1,1/3,1/2},{1,1/3,1/2}}] and the boundary of Tetrahedron[{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}]:
Find the intersection for three random planes:
Find the intersections of the spheres Sphere[{1/3 Cos[k 2π/3],1/3 Sin[k 2π/3],0}] for k=0,1,2:
Find all the intersections of exactly three planes among 10 random planes:
Use BooleanCountingFunction to find the condition of exactly three things being true:
Properties & Relations (7)
Solutions approximately satisfy the equations:
Solutions are given as replacement rules and can be directly used for substitution:
NSolve uses {} to represent the empty or no solution:
NSolve uses {{}} to represent the universal solution or that all points satisfy the equations:
For univariate equations, NSolve repeats solutions according to their multiplicity:
Find solutions over specified domains:
NSolve is a global equation solver:
FindRoot is a local equation solver:
NSolve gives approximate results:
Use Solve to get exact solutions:
Use FindInstance to get exact solution instances:
Use NDSolve to solve differential equations numerically:
Possible Issues (3)
Solutions obtained with machine-precision numeric computations may not be accurate:
With higher WorkingPrecision more accurate results are produced:
Approximate solutions may not satisfy the equations due to numeric errors:
The equations are satisfied up to a certain tolerance:
Using higher WorkingPrecision will give solutions with smaller tolerance:
If the solutions set is infinite, NSolve gives its intersection with random hyperplanes:



Use ContourPlot and ContourPlot3D to view the real part of solutions:
Text
Wolfram Research (1991), NSolve, Wolfram Language function, https://reference.wolfram.com/language/ref/NSolve.html (updated 2014).
CMS
Wolfram Language. 1991. "NSolve." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/NSolve.html.
APA
Wolfram Language. (1991). NSolve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NSolve.html