I did some calculations in sympy, and the result is, after all, a set of constants. One of them is inserted directly into the fragment below:
from sympy import * expr = (18**(Rational(1, 3))/(6*(3 + sqrt(3)*I)**(Rational(1, 3))) + 12**(Rational(1, 3))*(3 + sqrt(3)*I)**(Rational(1, 3))/12) print(expr.evalf()) print(expr.simplify())
It returns
0.56857902130163 + 0.e-22*I 18**(1/3)/(6*(3 + sqrt(3)*I)**(1/3)) + (36 + 12*sqrt(3)*I)**(1/3)/12
therefore, the expression appears to be a real number, but sympy cannot simplify it. With pen and paper, I simplified this for
cos(pi/18) / sqrt(3)
which is consistent with the numerical value returned by evalf() .
I tried many of the various simplification functions, but none of them seem to be able to reduce the expression. Using Type Substitutions
expr.subs(3 + sqrt(3)*I, sqrt(12) * exp(I*pi/6))
improves expression, but simplex cannot conclude that it is real. Using Eulerβs formula for substitution,
expr.subs(3 + sqrt(3)*I, sqrt(12) * (cos(pi/6) + I*sin(pi/6)))
sympy may finally conclude that the expression is real, but the expression itself explodes in size when printed (even if I try to simplify after the substitution).
Is there a better way to try to reduce this? I have many similar expressions for complex constants that I would like to know for sure are real (or not).