#include #include #include /******************************************************************************\对一个复数 x 开 n 次方\******************************************************************************/std::complex sqrtn(const std::complex&x,double n){double r = _hypot(x.real(),x.imag()); //模if(r > 0.0){double a = atan2(x.imag(),x.real()); //辐角n = 1.0 / n;r = pow(r,n);a *= n;return std::complex(r * cos(a),r * sin(a));}return std::complex();}/******************************************************************************\使用费拉里法求解一元四次方程 a*x^4 + b*x^3 + c*x^2 + d*x + e = 0\******************************************************************************/void Ferrari(std::complex x,std::complex a,std::complex b,std::complex c,std::complex d,std::complex e){a = 1.0 / a;b *= a;c *= a;d *= a;e *= a;std::complex P = (c * c + 12.0 * e - 3.0 * b * d) / 9.0;std::complex Q = (27.0 * d * d + 2.0 * c * c * c + 27.0 * b * b * e - 72.0 * c * e - 9.0 * b * c * d) / 54.0;std::complex D = sqrtn(Q * Q - P * P