# Why does Sage seem to be wrong?

I ask Sage to calculate the following expression

x = (70 - 13*sqrt(29))^(1/3) + (70 + 13*sqrt(29))^(1/3)
print x
print N(x)


(13*sqrt(29) + 70)^(1/3) + (-13*sqrt(29) + 70)^(1/3)
5.28887360535083 + 0.166781253811029*I


But my calculator says 5. I don't understand why?

edit retag close merge delete

1

You should update your version of Sage: the syntax "print x" (rather than "print(x)") indicates that you are using a pretty old version.

Sort by » oldest newest most voted This is because numbers have more than one cube root, and Sage is choosing a complex (non-real) cube root for the first term in your sum. In more detail, Sage is very cautious, with good mathematical reason, when raising negative numbers to non-integer exponents. The first summand is negative, and that's where the issue arises. (Your calculator, on the other hand, is choosing the real cube root.) To force Sage to use the real root, it's best to work with numerical approximations throughout:

a = 70 - 13*sqrt(29)
b = 70 + 13*sqrt(29)
x = real_nth_root(N(a), 3) + real_nth_root(N(b), 3)
print(x)


should print

5.00000000000009

more

Thank you for your quick reply, which I understood, but as I'm still working with Sage v7.3 the instruction real_nth_root(N(a), 3) doesn't work. I'm looking for an equivalent. I think I'll have to update my version of Sage. Thanks again.

Version 7.3 is almost 7 years old, so yes, you should upgrade :)

I'd nuance @John Palmieri 's answer by noting that $\sqrt[n]{x}$ is a multivalued function of $x$, therefore ambiguous. In the (frequent) case $n=2,\ x\in\mathbb{R}^{+}$, the usual convention is to use the positive real root of $x$ as the sole value. This convention breaks for $x\not\in\mathbb{R}^{+}$ since $i$ denotes a solution of the equation $x^2+1=0$ (which one ?)... The same ambiguity extends to cases $n>2$...

You can see the possible values of your multivalued expression that way :

a = 70 - 13*sqrt(29)
b = 70 + 13*sqrt(29)
t=var("t")
aa=(t^3-a).roots(ring=QQbar, multiplicities=False)#  ; print("a in ", aa)
bb=(t^3-b).roots(ring=QQbar, multiplicities=False)#  ; print("b in ", bb)
print ("x in ", [a+b for a, b in cartesian_product([aa, bb]).list()])


which prints (see there) :

a in  [-0.1925824035672521?, 0.09629120178362601? - 0.1667812538111072?*I, 0.09629120178362601? + 0.1667812538111072?*I]
b in  [5.192582403567252?, -2.596291201783626? - 4.496908272733301?*I, -2.596291201783626? + 4.496908272733301?*I]
x in  [5.000000000000000?, -2.788873605350878? - 4.496908272733301?*I, -2.788873605350878? + 4.496908272733301?*I, 5.288873605350878? - 0.1667812538111072?*I, -2.500000000000000? - 4.663689526544407?*I, -2.500000000000000? + 4.330127018922193?*I, 5.288873605350878? + 0.1667812538111072?*I, -2.500000000000000? - 4.330127018922193?*I, -2.500000000000000? + 4.663689526544407?*I]


Sorry to muddy the waters...

HTH,

more