Given a formula
$$x^3+ax^2+bx+c=0$$
how can I get the value of x without having an $i$ in my roots? Because Cardano's formula does have imaginary numbers if the discriminant is less than zero. My task is to generalize it and all the cases about the discriminant is applied without having a restriction in imaginary numbers.
I have been using Cardano's formula but if the cases are not suitable there is a root with imaginary numbers.
If you read up on the casus irreducibilis, you will find that it is impossible to express the general cubic formula in such a way that real roots will always be expressed without intermediate complex numbers. This is actually a (possibly) historical reason that complex numbers were originally accepted in algebra, since not only equations with complex roots such as $x^2 + 1 = 0$, but also certain cubic equations with only real roots, required complex numbers to express those roots.