I'm trying to solve a problem that requires me to find the roots of the equation $$-x^4+10x^2-x-20=0$$

By making use of Newton's method, symbolab's equation calculator has found one root to be

$x\approx -2.79129... : x=-\frac{\sqrt{21}+1}{2}$

My question is pretty basic, actually: how did they convert the decimal number on the left to the neat faction on the right? I couldn't get to it the way I've learned to convert decimals. Thanks very much in advance.

  • 2
    $\begingroup$ I don't know exactly how they passed from the approximate decimal value to an exact algebraic representation, but I assure you it has nothing to do with you being deficient in decimals :) Surely there is an algorithm at work which uses the approximate decimal value as a starting point and determines the algebraic representation with some work. $\endgroup$
    – Chris
    Jul 6, 2017 at 3:15
  • 3
    $\begingroup$ There's a website mrob.com/pub/ries where you can put in a decimal number and it tries to match it. You can specify "algebraic" to eliminate $\pi$'s and such. I don't know how the algorithm works. I put your approximation in and it didn't get the exact answer. Then I put in a 14-decimal place approximation and it got an exact match. $\endgroup$
    – B. Goddard
    Jul 6, 2017 at 3:22
  • 6
    $\begingroup$ They didn't. They got the neat and accurate fraction on the right first via the quadratic formula. Then the put it into a calculator and got the approximate inaccurate decimal on the left. $\endgroup$
    – fleablood
    Jul 6, 2017 at 3:42
  • 2
    $\begingroup$ HOW do you think that? The given equation is not a quadratic equation nor can it easily be made into one. Further, the post specifically said that it was done "By making use of Newton's method", $\endgroup$
    – user247327
    Jul 6, 2017 at 12:04
  • $\begingroup$ @B.Goddard I think that those "inverse calculators" work by matching your sequence of digits against a database of precomputed decimal expansions, essentially. $\endgroup$ Jul 6, 2017 at 12:07

4 Answers 4


You have accepted another answer, but here is an explanation of how a program or web site could find an expression such as the one given for a floating-point value.

If you have reason to believe that a given floating-point number is a quadratic irrational number, a program can check if that hypothesis is reasonable and, if it is reasonable, give an expression for the value.

The program first finds the continued fraction expansion of the given value. In our case, it is easier to look at $|x|\approx 2.79128784747792$. The first quotient is $\mathrm{int}(x)=2$. To get the later ones, replace $x$ with $\dfrac 1{\mathrm{frac}(x)}$ and take the integer part again. For the given value we get the quotients

$$[2; 1, 3, 1, 3, 1, 3, \ldots]$$

We see that the quotients are repeating. If we keep going, the inherent inaccuracies of the floating-point format will ruin the pattern, but we have good reason to believe that the repetition would be infinite. This repeating pattern in a continued-fraction expansion means the value is a quadratic irrational.

Plain algebra can then be used to find an expression for that value. In this case we see for the repeating part that

$$u=1+\frac 1{3+\frac 1u}$$

Solving that leads to the quadratic equation $3u^2-3u-1=0$, which has the one positive solution $u=\dfrac{3+\sqrt{21}}{6}$, then we find $x$ from

$$x=2+\frac 1u$$

which of course is $x=\dfrac{1+\sqrt{21}}{2}$. This entire process can be automated. Again, the limitations of the floating-point format make this uncertain to get the exact correct value, but using extended-precision arithmetic can make mistakes very few.

  • 2
    $\begingroup$ Yes, yes, yes. Quadratics have very well-known and simple continued fractions, and would be the first tool I would use to write a program to detect quadratic (short of symbolic calculations of course, but that requires a TON more sophistication) $\endgroup$ Jul 6, 2017 at 16:24

Almost certainly the polynomial was factored to get $-(x^2+x-5)(x^2-x-4)$ and then the quadratic equation was used to solve for the zeros of each factor.

  • $\begingroup$ hardly matters, the one with five is $x^2 + x - 5.$ I put an answer, in my (mostly losing) battle that the students can do many of these tasks by hand, especially when the problem is constructed by an author who intends them done by hand. $\endgroup$
    – Will Jagy
    Jul 6, 2017 at 19:03

You are making an assumption that they figured the decimal first and converted it the fraction second.

In actuality they did the exact opposite. They used the quadratic formula to get the fraction, Which is accurate and exact. Then they calculated and estimated it to be approximately the decimal on the right.

Converting an irrational decimal to a fraction with the nescessary symbols is impossible for the obvious reason we can not ever have a complete decimal representation of an irrational number.

  • 4
    $\begingroup$ The inverse symbolic calculator exists, though. $\endgroup$ Jul 6, 2017 at 6:42
  • 6
    $\begingroup$ I wouldn't say that OP is making an assumption here - the steps listed on the page they link show first finding approximate solutions, and then converting those to the exact answer (with the rather unilluminative instruction "approximate to algebraic form"). The exact solutions are simple enough that it's entirely reasonable that the program was able to go from the decimal approximation to that exact form, especially if it's only looking for simple expressions, say, of the form $p+\sqrt{q}$ with rational $p$, $q$. $\endgroup$
    – Carmeister
    Jul 6, 2017 at 6:57
  • 8
    $\begingroup$ Agree with @Carmeister. Strange that this is the accepted answer, because it is very unlikely they did it this way. The symbolab page is very explicit that they use Newton-Raphson to find the solutions, and then "Approximate to algebraic form" as the last step. $\endgroup$
    – fishinear
    Jul 6, 2017 at 10:29
  • 3
    $\begingroup$ But you can't use the quadratic formula with the original equation. $\endgroup$
    – Teepeemm
    Jul 6, 2017 at 15:54
  • $\begingroup$ Perhaps so. But then the question as asked "My question is pretty basic, actually:..I couldn't get to it the way I've learned to convert decimals" is a misunderstanding as this is not in the least bit basic nor anything a mere mortal is expected to be able to do. Nor is it a mathematical certainty. I will admit, I did not address the OP's question of how the algorithm worked. I felt the more pertenent issue was mathematical certainty does not go from decimal to accuality but the other way aroud. $\endgroup$
    – fleablood
    Jul 6, 2017 at 15:57

Bit late; I would emphasize that we can factor the polynomial ourselves, and this one is not difficult. We check that there are no rational roots. After that, we need only try integer constants $a,b,c,d$ with $$ (x^2 + ax + b)(x^2 + cx + d) = x^4 + (a+c)x^3 + \cdots $$ Since we are trying to get $x^4 - 10 x^2 + x + 20,$ we see that $c+a = 0.$ $$ (x^2 + ax + b)(x^2 -ax + d) = x^4 + (b+d - a^2)x^2 + a(d-b)x + bd. $$ From $a(d-b)= 1$ we have $a = \pm 1.$ Both work, they just switch $b,d.$ First, $a=1$ gives $$ (x^2 + x + b)(x^2 -x + d) = x^4 + (b+d - 1)x^2 + (d-b)x + bd, $$ so $b+d = -9, d - b = 1.$ Then $2d = -8,$ $d= -4,$ $b=-5,$ and we check $$ (x^2 + x -5)(x^2 -x -4) = x^4 -10 x^2 + x + 20. $$



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .