# Revision history [back]

When solving the roots of a 3rd degree polynomial, sometimes the real solutions are expressed in terms of the imaginary unit for instance when using The Cubic Formula : "Cardan's formula has the drawback that it may bring such square roots into play in intermediate steps of computation, even when those numbers do not appear in the problem or its answer. For instance, consider the cubic equation x^3-15x-4=0. (This example was mentioned by Bombelli in his book in 1572.) That problem has real coefficients, and it has three real roots for its answers. But if we apply Cardano's formula to this example, we use a=1, b=0, c=-15, d=-4, and we find that we need to take the square root of -109 in the resulting computation. Ultimately, the square roots of negative numbers would cancel out later in the computation".

If you provide the ComplexDoubleField to compute an approximation of the roots, here is what you get:

sage: p = (x^3-x) - (3*x^2 - 1)
sage: CDF
Complex Double Field
sage: p.roots(ring=CDF)
[(-0.6751308705666456, 1), (0.4608111271891108, 1), (3.2143197433775406, 1)]
sage: p.roots(ring=CDF, multiplicities=False)
[-0.6751308705666456, 0.4608111271891108, 3.2143197433775406]