134 std::complex<realT> p, q, S, Q, Delta0, Delta1;
136 p = ( 8.0 * a * c - 3.0 * b * b ) / ( 8.0 * a * a );
138 q = ( b * b * b - 4.0 * a * b * c + 8.0 * a * a * d ) / ( 8.0 * a * a * a );
140 Delta0 = c * c - 3.0 * b * d + 12.0 * a * e;
141 Delta1 = 2.0 * c * c * c - 9.0 * b * c * d + 27.0 * b * b * e + 27.0 * a * d * d - 72.0 * a * c * e;
143 Q = pow(
static_cast<realT
>( 0.5 ) *
144 ( Delta1 + sqrt( Delta1 * Delta1 -
static_cast<realT
>( 4 ) * Delta0 * Delta0 * Delta0 ) ),
147 S =
static_cast<realT
>( 0.5 ) *
148 sqrt( -
static_cast<realT
>( 2.0 / 3.0 ) * p +
static_cast<realT
>( 1.0 / ( 3.0 * a ) ) * ( Q + Delta0 / Q ) );
152 x[0] = -b / ( 4 * a ) - S +
153 static_cast<realT
>( 0.5 ) * sqrt(
static_cast<realT
>( -4 ) * S * S -
static_cast<realT
>( 2 ) * p + q / S );
154 x[1] = -b / ( 4 * a ) - S -
155 static_cast<realT
>( 0.5 ) * sqrt(
static_cast<realT
>( -4 ) * S * S -
static_cast<realT
>( 2 ) * p + q / S );
156 x[2] = -b / ( 4 * a ) + S +
157 static_cast<realT
>( 0.5 ) * sqrt(
static_cast<realT
>( -4 ) * S * S -
static_cast<realT
>( 2 ) * p - q / S );
158 x[3] = -b / ( 4 * a ) + S -
159 static_cast<realT
>( 0.5 ) * sqrt(
static_cast<realT
>( -4 ) * S * S -
static_cast<realT
>( 2 ) * p - q / S );
void quarticRoots(std::vector< std::complex< realT > > &x, realT a, realT b, realT c, realT d, realT e)
Find the roots of the general quartic equation.
realT cubicDescriminant(const realT &a, const realT &b, const realT &c, const realT &d)
Calculate the descriminant for the general cubic.
void cubicDepressed(realT &p, realT &q, const realT &a, const realT &b, const realT &c, const realT &d)
Convert a general cubic equation to depressed form.