version 0.6.0

Functions/Subroutines

pure subroutine, public mod_polynomial_roots::solve_quadratic (a, b, x)
 Solve quadratic equation in monic form. More...
 
pure subroutine, public mod_polynomial_roots::solve_cubic (a, b, c, x)
 Solve cubic equation in monic form. More...
 
pure subroutine, public mod_polynomial_roots::solve_quartic (a, b, c, d, x)
 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_roots::solve_cubic ( double precision, intent(in)  a,
double precision, intent(in)  b,
double precision, intent(in)  c,
complex(kind=8), dimension(3), intent(out)  x 
)

The cubic equation to solve must be in the form:

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

References:

  • Strobach, P. (2011). Solving cubics by polynomial fitting. Journal of computational and applied mathematics, 235(9), 3033-3052. doi:10.1016/j.cam.2010.12.025
Parameters
[in]a,b,cCoefficients of the third order polynomial in monic form.
[out]xThe three complex roots.

◆ solve_quadratic()

pure subroutine, public mod_polynomial_roots::solve_quadratic ( double precision, intent(in)  a,
double precision, intent(in)  b,
complex(kind=8), dimension(2), intent(out)  x 
)

The quadratic equation to solve must be in the form:

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

Reference:

  • Vetterling, W. T., Teukolsky, S. A., Press, W. H., & Flannery, B. P. (1992). Numerical recipes in Fortran 77: the art of scientific computing. Cambridge University Press, London. ISBN:978-0521430647
Parameters
[in]a,bCoefficients of the second order polynomial in monic form.
[out]xThe two complex roots.

◆ solve_quartic()

pure subroutine, public mod_polynomial_roots::solve_quartic ( double precision, intent(in)  a,
double precision, intent(in)  b,
double precision, intent(in)  c,
double precision, intent(in)  d,
complex(kind=8), dimension(4), intent(out)  x 
)

The quartic equation to solve must be in the form:

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

References:

  • Strobach, P. (2010). The fast quartic solver. Journal of computational and applied mathematics, 234(10), 3007-3024. doi:10.1016/j.cam.2010.04.015
Parameters
[in]a,b,c,dCoefficients of the fourth order polynomial in monic form.
[out]xThe four complex roots.