# NSolve

NSolve[expr,vars]

attempts to find numerical approximations to the solutions of the system expr of equations or inequalities for the variables vars.

NSolve[expr,vars,Reals]

finds solutions over the domain of real numbers.

# 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&&varsReals,vars,Complexes] solves for real values of variables, but function values are allowed to be complex.
• NSolve[,xreg,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 all

## Basic Examples(5)

Approximate solutions to a polynomial equation:

Approximate real solutions to a polynomial equation:

Approximate solutions to a system of polynomial equations:

Approximate real solutions to a system of polynomial equations:

Solve equations in a geometric region:

## Scope(45)

### Complex Equations in One Variable(8)

Univariate polynomial equations:

Polynomial equations with inexact coefficients:

Polynomial equations with multiple roots:

Algebraic equations:

Transcendental equations:

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)

Systems of linear equations:

Linear equations with inexact coefficients:

Underdetermined systems of linear equations:

Linear equations with no solutions:

Systems of polynomial equations:

Underdetermined systems of polynomial equations:

Algebraic equations:

Transcendental equations:

### Real Equations in One Variable(11)

Polynomial equations:

Polynomial equations with multiple roots:

Algebraic equations:

Piecewise equations:

Transcendental equations, solvable using inverse functions:

Transcendental equations, solvable using special function zeros:

Transcendental inequalities, solvable using special function zeros:

Exp-log equations:

High-degree sparse polynomial equations:

Equations involving irrational real powers:

Equation with a double root:

Tame elementary function equations:

Elementary function equations in bounded intervals:

Holomorphic function equations in bounded intervals:

### Systems of Real Equations and Inequalities in Several Variables(9)

Linear systems:

Polynomial systems:

Quantified polynomial systems:

Algebraic systems:

Piecewise systems:

Transcendental systems solvable using inverse functions:

Systems exp-log in the first variable and polynomial in the other variables:

Quantified system:

Systems elementary and bounded in the first variable and polynomial in the other variables:

Quantified system:

Systems holomorphic and bounded in the first variable and polynomial in the other variables:

Quantified system:

### Systems with Mixed Variable Domains(1)

Mixed real and complex variables:

### Geometric Regions(8)

Solve over special regions in 2D:

Plot it:

Solve over special regions in 3D:

Plot it:

An implicitly defined region:

A parametrically defined region:

Derived regions:

Plot it:

Regions dependent on parameters:

Plot it:

Find values of parameters , , and for which the circles contain the given points:

Plot it:

Use to specify that is a vector in :

In this case is a vector in :

## Generalizations & Extensions(1)

All variables are solved for:

Working precision can be given as the last argument:

## Options(3)

### Method(1)

By default NSolve introduces slicing hyperplanes for underdetermined complex systems:

With Method->{"UseSlicingHyperplanes"->False}, NSolve gives parametric solutions:

### VerifySolutions(1)

NSolve verifies solutions obtained using non-equivalent transformations:

With , NSolve does not verify the solutions:

Some of the solutions returned with 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:

This computes the solutions using 50-digit precision:

## 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}}]:

Plot it:

Find the intersections of InfiniteLine[{0,0},{1,1}] and Circle[{0,0},1]:

Plot it:

Find all pairwise intersections between five random lines:

Use BooleanCountingFunction to express that exactly two conditions are true:

Plot it:

Find the pairwise intersections of the circles Circle[{1/3 Cos[k 2π/5],1/3 Sin[k 2π/5]}] for k=0,,4:

Plot it:

Find the intersection of InfiniteLine[{{-1,1,1},{1,1,1}}] and InfinitePlane[{{2,0,0},{0,2,0},{0,0,2}}]:

Plot it:

Find the intersections of InfiniteLine[{{-1,1,1},{1,1,1}}] and Sphere[{0,0,0},3]:

Plot it:

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}}]:

Plot it:

Find the intersection for three random planes:

Plot it:

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:

Plot it:

Find all the intersections of exactly three planes among 10 random planes:

Use BooleanCountingFunction to find the condition of exactly three things being true:

Plot it:

## 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:

## Neat Examples(1)

Solve the equation :

Wolfram Research (1991), NSolve, Wolfram Language function, https://reference.wolfram.com/language/ref/NSolve.html (updated 2014).

#### 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

#### BibTeX

@misc{reference.wolfram_2022_nsolve, author="Wolfram Research", title="{NSolve}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/NSolve.html}", note=[Accessed: 08-August-2022 ]}

#### BibLaTeX

@online{reference.wolfram_2022_nsolve, organization={Wolfram Research}, title={NSolve}, year={2014}, url={https://reference.wolfram.com/language/ref/NSolve.html}, note=[Accessed: 08-August-2022 ]}