Class cubic_real_coeff_cern (o2scl)

O2scl : Class List

class o2scl::cubic_real_coeff_cern : public o2scl::cubic_real_coeff

Solve a cubic with real coefficients and complex roots (CERNLIB)

Note

The function rrteq3() is based on the CERNLIB routine of the same name, but differs slightly. See the documentation of that function for details.

Public Functions

cubic_real_coeff_cern()
~cubic_real_coeff_cern()
int solve_rc(const double a3, const double b3, const double c3, const double d3, double &x1, std::complex<double> &x2, std::complex<double> &x3)

Solves the polynomial \( a_3 x^3 + b_3 x^2 + c_3 x + d_3= 0 \) giving the real solution \( x=x_1 \) and two complex solutions \( x=x_2 \) , and \( x=x_3 \) .

int rrteq3(double r, double s, double t, double x[], double &d)

The CERNLIB-like interface.

This function computes the roots of the cubic equation

\[ x^3 + r x^2 + s x + t =0 \]
returning the value of the discriminant in d and the roots in the array x. If the discriminant is negative, then all three real roots are stored in x. Otherwise, the real root is stored in x[0] and the real and imaginary parts of the complex conjugate roots are stored in x[1] and x[2], respectively. This differs from the CERNLIB routine where the results were stored in x[1], x[2], and x[3] instead.

Another small change is that the discriminant for the resolvent cubic is evaluated slightly differently in order to improve the properties in the case where the roots are not all of order unity. The default CERNLIB behavior can be restored by setting improve_scale to false.

const char *type()

Return a string denoting the type (“cubic_real_coeff_cern”)

Public Members

double eps

Numerical tolerance (default \( 10^{-6} \))

double delta

Numerical tolerance (default \( 10^{-15} \))

bool improve_scale

Improve algorithm for poorly-scaled roots (default true)