I know there are three real roots for cubic however cubic formula is giving me non-real answer. What am I doing wrong?

I didn't check your calculations, but it seems you got into the point which actually made people turn their attention to complex numbers. Complex numbers were not "invented" in order to solve quadractic equations as some people usually tell us, but to solve cubic equations. People discovered a formula for the roots of a cubic polynomial, but then later discovered that in some situations (actually, a lot of them), the equations passed necessarily over complex numbers. Actually, even in situations where all roots are real this happen.

If you do the calculations correctly, the complex numbers will cancel themselves in the end.


Okay, so you're getting that operands of the cube root parts of the formula will look like this: $$p + q i \qquad\text{and}\qquad p - q i$$ with some pesky non-zero $q$ (namely, $\sqrt{108}$). Well, these values are conjugates, so that their respective (principal) cube roots are conjugates, as well. For the $x_1$ value in your formula, these conjugate cube roots add together, and their imaginary parts conveniently cancel. The same kind of cancellation happens for the $x_2$ and $x_3$ values, too, because the factors $\frac{1}{2}(1+i\sqrt{3})$ and $\frac{1}{2}(1-i\sqrt{3})$ are themselves conjugates. When the dust settles, you'll have the three real roots you expect.

As @Aloizio points out, this is historically how imaginary numbers snuck into mathematics: as temporary diversions on the way to real solutions of cubic equations. These numbers seemed weird, maybe even scary, but they cancelled in the end so no harm done. Then people started to wonder about a world in which these things didn't always cancel ...