Tools to compute the real roots of quadratic, cubic, and quartic polynomials. More...
Functions/Subroutines | |
pure subroutine, public | mod_polynomial_real_roots::solve_quadratic (a, b, x, n_roots) |
Solve quadratic equation in monic form. | |
pure subroutine, public | mod_polynomial_real_roots::solve_cubic (a, b, c, x, n_roots) |
Solve cubic equation in monic form. | |
pure subroutine, public | mod_polynomial_real_roots::solve_quartic (a, b, c, d, x, n_roots) |
Solve quartic equation in monic form. | |
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.
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 \]
[in] | a,b,c | Coefficients of the third order polynomial in monic form. |
[out] | x | The three real roots. |
[out] | n_roots | Number of real roots. |
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 \]
[in] | a,b | Coefficients of the second order polynomial in monic form. |
[out] | x | Real roots of the polynomial. |
[out] | n_roots | Number of real roots. |
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 \]
[in] | a,b,c,d | Coefficients of the fourth order polynomial in monic form. |
[out] | x | The four real roots. |
[out] | n_roots | Number of roots |