converts the number x to one of the "simplest" algebraic numbers that approximates it well.
RootApproximant[x,n]
finds an algebraic number of degree at most n that approximates x.
RootApproximant
converts the number x to one of the "simplest" algebraic numbers that approximates it well.
RootApproximant[x,n]
finds an algebraic number of degree at most n that approximates x.
Details and Options
- For degrees above 2, RootApproximant generates Root objects.
- RootApproximant[x] effectively tests the total number of bits in the description of x by successively higher-degree algebraic numbers, and returns the first case for which the number of bits is small.
- Results from RootApproximant may not be unique.
- MinimalPolynomial yields the minimal polynomial for the result of RootApproximant.
- The option Method->{"DegreeCost"->p} specifies an additional cost p to be used for each successively higher power in determining the "simplest" approximation.
Examples
open all close allBasic Examples (2)
Scope (4)
There is no simple quadratic approximation to N
:
RootApproximant[N[Sqrt[2] + Sqrt[3]], 2]At degree 4, there is a simple answer, which turns out to be equal to
:
RootApproximant[N[Sqrt[2] + Sqrt[3]], 4]RootReduce[Sqrt[2] + Sqrt[3]] == %Machine precision is not enough to recover the Root object equal to
:
RootApproximant[N[Sqrt[2] + Sqrt[3] + Sqrt[5]], 8]RootReduce[Sqrt[2] + Sqrt[3] + Sqrt[5]] == %30 digits of precision suffice to recover the exact value here:
RootApproximant[N[Sqrt[2] + Sqrt[3] + Sqrt[5], 30], 8]RootReduce[Sqrt[2] + Sqrt[3] + Sqrt[5]] == %When given exact input, RootApproximant uses machine-precision approximations:
RootApproximant[E, 3]RootApproximant[N[E], 3]%% == %RootApproximant works with complex numbers:
RootApproximant[N[Sqrt[2] + I], 4]Options (1)
Applications (2)
Find successive algebraic approximations to
:
Table[RootApproximant[N[Pi, n]], {n, 5}]A complicated radical expression:
expr = (-1 + Sqrt[2] - Sqrt[(1 + 2 Sqrt[2] - s) (-1 + s)] + s) (-1 - Sqrt[2] + Sqrt[2] s - Sqrt[-1 - 2 Sqrt[2] + 2 (2 + Sqrt[2] - s) s]) - (-1 - Sqrt[2] + Sqrt[2] s + Sqrt[-1 - 2 Sqrt[2] + 2 (2 + Sqrt[2] - s) s]) (-2 - 2 Sqrt[2] + 2 s + 2 Sqrt[1 - (1/4) (-1 - Sqrt[2] + Sqrt[(1 + 2 Sqrt[2] - s) (-1 + s)] + s)^2]);Use FindRoot to find the real root near 2.5:
x = s /. FindRoot[expr == 0, {s, 2.5}, WorkingPrecision -> 100]//ChopUse RootApproximant to find an algebraic number close to the root:
a = RootApproximant[x]Check whether the result is a root of the original expression:
expr /. s -> a//RootReduceProperties & Relations (3)
RootApproximant gives a Root object close to a given algebraic number:
RootApproximant[Sqrt[2 + Sqrt[3]]]The Root object found may not be exactly equal to the input:
a = Sqrt[2 + Sqrt[3 + Sqrt[5 + Sqrt[7]]]];
b = RootApproximant[a]N[a - b, 20]Use RootReduce to find exact Root object representations of algebraic numbers:
RootReduce[a]Specifying a linear polynomial effectively finds a rational approximation to x:
RootApproximant[Pi, 1]Rationalize also gives a rational approximation, but it need not be the same:
Rationalize[N[π], 0]Interestingly, the approximations can be found among continued fraction convergents:
FromContinuedFraction[ContinuedFraction[N[π], 15]]FromContinuedFraction[ContinuedFraction[π, 15]]Use LatticeReduce to recognize linear combinations of more general functions:
v = {1, ArcTan[1], ArcTan[1 / 5], ArcTan[1 / 239], 1};{a0, a1, a2, a3, a4} = Round[10 ^ 20 v];b = LatticeReduce[{{1, 0, 0, 0, -a0}, {0, 1, 0, 0, -a1}, {0, 0, 1, 0, -a2}, {0, 0, 0, 1, -a3}}]b[[1]].vN[%]Possible Issues (1)
Recognizing an algebraic number may require using higher precision:
a = Sqrt[5 + 2 6 ^ (1 / 3)];
b = RootApproximant[N[a], 10]RootReduce[a] == bProviding the correct degree improves the chances of recognizing an algebraic number:
c = RootApproximant[N[a], 6]RootReduce[a] == cA penalty may be used to lower the degree; here it does not help in recognizing the number:
RootApproximant[N[a], 10, Method -> {"DegreeCost" -> #}]& /@ {1, 2, 3}N[% - a, 20]Using a higher-precision approximation allows the algebraic number to be recognized:
RootApproximant[N[a, 25], 10]RootReduce[a] == %Related Guides
Text
Wolfram Research (2007), RootApproximant, Wolfram Language function, https://reference.wolfram.com/language/ref/RootApproximant.html (updated 2008).
CMS
Wolfram Language. 2007. "RootApproximant." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008. https://reference.wolfram.com/language/ref/RootApproximant.html.
APA
Wolfram Language. (2007). RootApproximant. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RootApproximant.html
BibTeX
@misc{reference.wolfram_2026_rootapproximant, author="Wolfram Research", title="{RootApproximant}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/RootApproximant.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rootapproximant, organization={Wolfram Research}, title={RootApproximant}, year={2008}, url={https://reference.wolfram.com/language/ref/RootApproximant.html}, note=[Accessed: 12-June-2026]}