version 0.6.0

Functions/Subroutines

pure subroutine, public mod_polynomial_real_roots::solve_quadratic (a, b, x, n_roots)
 Solve quadratic equation in monic form. More...
 
pure subroutine, public mod_polynomial_real_roots::solve_cubic (a, b, c, x, n_roots)
 Solve cubic equation in monic form. More...
 
pure subroutine, public mod_polynomial_real_roots::solve_quartic (a, b, c, d, x, n_roots)
 Solve quartic equation in monic form. More...
 

Detailed Description

The equations must be represented in the monic form, that is the leading coefficient of the polynomial is equal to 1:

\[ x^n + a_{n-1} x^{n-1} + \cdots + a_0 = 0 \]

The coefficients must be real numbers.

Function/Subroutine Documentation

◆ solve_cubic()

pure subroutine, public mod_polynomial_real_roots::solve_cubic ( double precision, intent(in)  a,
double precision, intent(in)  b,
double precision, intent(in)  c,
double precision, dimension(3), intent(out)  x,
integer, intent(out)  n_roots 
)

The cubic equation to solve must be in the form:

\[ x^3 + ax^2 + bx + c = 0 \]

Parameters
[in]a,b,cCoefficients of the third order polynomial in monic form.
[out]xThe three real roots.
[out]n_rootsNumber of real roots.

◆ solve_quadratic()

pure subroutine, public mod_polynomial_real_roots::solve_quadratic ( double precision, intent(in)  a,
double precision, intent(in)  b,
double precision, dimension(2), intent(out)  x,
integer, intent(out)  n_roots 
)

The quadratic equation to solve must be in the form:

\[ x^2 + ax + b = 0 \]

Parameters
[in]a,bCoefficients of the second order polynomial in monic form.
[out]xReal roots of the polynomial.
[out]n_rootsNumber of real roots.

◆ solve_quartic()

pure subroutine, public mod_polynomial_real_roots::solve_quartic ( double precision, intent(in)  a,
double precision, intent(in)  b,
double precision, intent(in)  c,
double precision, intent(in)  d,
double precision, dimension(4), intent(out)  x,
integer, intent(out)  n_roots 
)

The quartic equation to solve must be in the form:

\[ x^4 + ax^3 + bx^2 + cx + d = 0 \]

Parameters
[in]a,b,c,dCoefficients of the fourth order polynomial in monic form.
[out]xThe four real roots.
[out]n_rootsNumber of roots