mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Declares and defines functions for finding roots. More...
Declares and defines functions for finding roots.
Definition in file roots.hpp.
Go to the source code of this file.
Namespaces | |
mx | |
The mxlib c++ namespace. | |
Functions | |
template<typename realT > | |
realT | mx::math::cubicDescriminant (const realT &a, const realT &b, const realT &c, const realT &d) |
Calculate the descriminant for the general cubic. More... | |
template<typename realT > | |
realT | mx::math::cubicDescriminant (const realT &p, const realT &q) |
Calculate the descriminant for the depressed cubic. More... | |
template<typename realT > | |
void | mx::math::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. More... | |
template<typename realT > | |
realT | mx::math::cubicRealRoot (const realT &p, const realT &q) |
Calculate the real root for a depressed cubic with negative descriminant. More... | |
template<typename realT > | |
void | mx::math::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. More... | |
void mx::math::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.
The general cubic is
\[ ax^3 + bx^2 + cx + d = 0 \]
which can be converted to compressed form
\[ t^3 + pt + q = 0 \]
[out] | p | the 1st order coefficient of the depressed cubic |
[out] | q | the 0th order coefficient of the depressed cubic |
[in] | a | the 3rd order coefficient of the general cubic |
[in] | b | the 2nd order coefficient of the general cubic |
[in] | c | the 1st order coefficient of the general cubic |
[in] | d | the 0th order coefficient of the general cubic |
Definition at line 81 of file roots.hpp.
References mx::astro::constants::c(), and mx::math::cubicDepressed().
Referenced by mx::math::cubicDepressed().
realT mx::math::cubicDescriminant | ( | const realT & | a, |
const realT & | b, | ||
const realT & | c, | ||
const realT & | d | ||
) |
Calculate the descriminant for the general cubic.
[in] | a | the 3rd order coefficient of the general cubic |
[in] | b | the 2nd order coefficient of the general cubic |
[in] | c | the 1st order coefficient of the general cubic |
[in] | d | the 0th order coefficient of the general cubic |
Definition at line 44 of file roots.hpp.
References mx::astro::constants::c(), and mx::math::cubicDescriminant().
Referenced by mx::math::cubicDescriminant().
realT mx::math::cubicDescriminant | ( | const realT & | p, |
const realT & | q | ||
) |
Calculate the descriminant for the depressed cubic.
[in] | p | the 0th order coefficient of the depressed cubic |
[in] | q | the 0th order coefficient of the depressed cubic |
Definition at line 62 of file roots.hpp.
References mx::math::cubicDescriminant().
realT mx::math::cubicRealRoot | ( | const realT & | p, |
const realT & | q | ||
) |
Calculate the real root for a depressed cubic with negative descriminant.
p
and q
std::runtime_error | if there are 3 real roots |
[in] | p | the 1st order coefficient of the depressed cubic |
[in] | q | the 0th order coefficient of the depressed cubic |
Definition at line 101 of file roots.hpp.
References mx::math::cubicRealRoot().
Referenced by mx::math::cubicRealRoot().