# Revision history [back]

First of all, let us move the fraction $1/6$ from the second formula inside the square root. As $1/36$. Then we get inside $\sqrt[3]{\ \dots\ }$ the following expression. $$-\frac g2 +\sqrt{\left(\frac g2\right)^2 +\left(\frac f3\right)^3}\ .$$ This is the way i would write the formula.

The second formula is correct.

The first one cannot work.

If the question is how to write sage code that checks that two symbolic algebraic expressions involving radicals inside radicals are, or are not equal - a purely programatic question, then this post is not an answer. If the way the formulas arise is the target, and if the check is / should be combined with the mathematic knowledge, then the following is what i would prefer. (There is also a detail in the choice of the third root in the two terms appearing in the formulas. They have to be correlated. This correlation cannot be explained in a trivial manner to the sage compiler by simply using a code fragment of the shape ( ... )^(1/3) + ( ... )^(1/3) , except we tacitly understand that the product of the cubic roots chosen ( ... )^(1/3)( ... )^(1/3) is fixed. And this is the reason why some textbooks prefer to put the second cubic root in a cumbersome expression.)

First of all, let $\epsilon$ be a primitive third root of unity. We can then factor the expression $$X^3 + A^3 + B^3 - 3XAB$$ as follows (over $\mathbb Q[A,B;X]$)

var( 'X,A,B' );
factor( X^3 + A^3 + B^3 - 3*A*B*X )


getting

(A^2 - A*B + B^2 - A*X - B*X + X^2)*(A + B + X)


-- and this is enough for our strict purposes, the factor $(X+A+B)$ is enough for the following -- but we can even force'' three linear factors after extending the coefficients from $\mathbb Q$ to $\mathbb Q[\epsilon]=\mathbb Q[\sqrt{-3}]$ . The corresponding code is:

F.<e> = CyclotomicField( 3 )
R.<A,B,X> = PolynomialRing( F )
factor( X^3 + A^3 + B^3 - 3*A*B*X )


And the factors are coming with the expected Galois symmetry:

(A + B + X) * (A + (e)*B + (-e - 1)*X) * (A + (-e - 1)*B + (e)*X)


Humanly written: $$X^3 + A^3 + B^3 - 3XAB = (X+A+B)(X^2+A^2 +B^2-XA-XB-AB) \ .$$ Even better: $$X^3 + A^3 + B^3 - 3XAB= (X+A+B)(X+\epsilon A+\epsilon^2 B)(X+\epsilon^2 A+\epsilon B)\ .$$ Now we plug in the following symbolic values for $A$ and $B$. Since i hate an excessive use of denominators (in $\LaTeX$), let $G=g/2$ and $F=f/3$. Let $A,B$ be the two values $$A ,B = -\left(\ - G\pm \sqrt{F^3+G^2}\ \right)^{1/3}\ .$$ Tacit convention: The two cubic roots are taken such that $AB$, constrained to be $$AB = \left(- G+\sqrt{F^3+G^2}\right)^{1/3}\left(- G-\sqrt{F^3+G^2}\right)^{1/3}$$ $$\qquad = \left(G^2 -(F^3+G^2)\right)^{1/3} = -(F^3)^{1/3}\in{F,\epsilon F,\epsilon^2 F}\ ,$$ is de facto exactly $AB=-F$. Then $$X^3 + A^3 + B^3 - 3XAB = X^3 -\left(- G+\sqrt{F^3+G^2}\right)-\left(- G-\sqrt{F^3+G^2}\right) -3X(-F)=\dots$$ This is $X^3 +3XF+2G = X^3+fX+g$.

The factor $(X+A+B)$ of $X^3+A^3+B^3-3ABX$ exposes the root $-(A+B)$ as in the second posted formula, the correct one. Let us give in sage a particular example:

sage: ( x^3 + 6*x + 2 ).roots( multiplicities=0 )

[1/2*2^(2/3)*(-I*sqrt(3) + 1) - 1/2*2^(1/3)*(I*sqrt(3) + 1),
1/2*2^(2/3)*(I*sqrt(3) + 1) - 1/2*2^(1/3)*(-I*sqrt(3) + 1),
-2^(2/3) + 2^(1/3)]


Here, $f=6$, $F=f/3=2$, $g=2$, $G=g/2=1$, then $\sqrt{F^3+G^2}=\sqrt{2^3+1^2}=3$, and we build $-1\pm 3$ and so on.