Given a formula
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.