Solving a quadratic equation with complex roots