WOLFRAM

NRoots[lhs==rhs,var]

yields a disjunction of equations which represent numerical approximations to the roots of a polynomial equation.

Details and Options

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

Numerically find the roots of a polynomial:

Out[1]=1

Change the result to rules:

Out[2]=2

Test the roots:

Out[3]=3

Scope  (1)Survey of the scope of standard use cases

Find the numerical roots of a polynomial with only real roots:

Out[1]=1

Find the numerical roots of a polynomial with real and complex roots:

Out[2]=2

Find the numerical roots of a polynomial with multiple roots:

Out[3]=3

Options  (5)Common values & functionality for each option

Method  (3)

Use the "Aberth" method, which simultaneously approximates all the roots of a univariate polynomial and converges cubically in general (but linearly at multiple zeros):

Out[3]=3

Use the "CompanionMatrix" method:

Out[1]=1

Use the "JenkinsTraub" method, which is a standard fast iterative globally convergent root-finding algorithm for polynomials:

Out[1]=1

PrecisionGoal  (1)

Specifying PrecisionGoal can improve the precision of the roots returned:

Use default precision:

Out[2]=2

Specify larger precisions:

Out[3]=3
Out[4]=4

Compare with the digits from an exact computation:

Out[5]=5

StepMonitor  (1)

Monitor the root-finding steps:

Out[1]=1


Using a different Method gives different convergence:

Out[2]=2

Applications  (1)Sample problems that can be solved with this function

Visualize the asymptotic rate of growth of the terms in the "look and say sequence," which is given by the positive real root of the following polynomial:

Find the roots numerically:

Out[3]=3

Visualize the roots in the complex plane, highlighting the unique positive one:

Out[4]=4

Properties & Relations  (7)Properties of the function, and connections to other functions

Return numerical roots using NRoots:

Out[7]=7
Out[8]=8

Compare with the numericization of roots returned by Roots:

Out[1]=1
Out[2]=2

Compare with the numerical roots returned by NSolve:

Out[1]=1

Compare with the numericization of roots returned by Solve:

Out[1]=1
Out[2]=2

Compare with the numericization of roots returned by Reduce:

Out[1]=1
Out[2]=2

Compare with a single numerical root returned by FindRoot:

Out[1]=1

Compare with the numericization of a single root returned by FindInstance:

Out[1]=1
Out[2]=2

Possible Issues  (3)Common pitfalls and unexpected behavior

NRoots returns unevaluated when called on a non-polynomial equation:

Out[2]=2

NRoots can return small imaginary parts for polynomials with real roots:

Out[2]=2

Use Chop to remove them:

Out[3]=3

Increasing MaxIterations does not necessarily give more accurate results:

Out[1]=1
Out[2]=2
Out[3]=3

In such cases, increasing the PrecisionGoal can sometimes give more precise results:

Out[4]=4

Interactive Examples  (1)Examples with interactive outputs

Interactively plot the real roots of a cubic polynomial:

Out[1]=1
Wolfram Research (1988), NRoots, Wolfram Language function, https://reference.wolfram.com/language/ref/NRoots.html (updated 2007).
Wolfram Research (1988), NRoots, Wolfram Language function, https://reference.wolfram.com/language/ref/NRoots.html (updated 2007).

Text

Wolfram Research (1988), NRoots, Wolfram Language function, https://reference.wolfram.com/language/ref/NRoots.html (updated 2007).

Wolfram Research (1988), NRoots, Wolfram Language function, https://reference.wolfram.com/language/ref/NRoots.html (updated 2007).

CMS

Wolfram Language. 1988. "NRoots." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/NRoots.html.

Wolfram Language. 1988. "NRoots." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/NRoots.html.

APA

Wolfram Language. (1988). NRoots. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NRoots.html

Wolfram Language. (1988). NRoots. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NRoots.html

BibTeX

@misc{reference.wolfram_2025_nroots, author="Wolfram Research", title="{NRoots}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/NRoots.html}", note=[Accessed: 29-March-2025 ]}

@misc{reference.wolfram_2025_nroots, author="Wolfram Research", title="{NRoots}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/NRoots.html}", note=[Accessed: 29-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_nroots, organization={Wolfram Research}, title={NRoots}, year={2007}, url={https://reference.wolfram.com/language/ref/NRoots.html}, note=[Accessed: 29-March-2025 ]}

@online{reference.wolfram_2025_nroots, organization={Wolfram Research}, title={NRoots}, year={2007}, url={https://reference.wolfram.com/language/ref/NRoots.html}, note=[Accessed: 29-March-2025 ]}