Find solutions for x3 +ax2 + bx + c = 0
or ax3 + bx2 + cx + d = 0
equation where a
, b
, c
, and d
are constants and x
is unknown variable.
This functions are available for floating point numbers only.
You can find more information in comments below.
// Find solutions of x * x * x + a * x * x + b * x + c = 0 equation and store them in x1, x2, and x3. Return number of found solutions including complex ones. Return either 2 or 3
template<class TYPE>
typename std::enable_if<std::is_floating_point<TYPE>::value, int>::type
SolveEquation3n(const TYPE a, const TYPE b, const TYPE c, TComplex<TYPE> &x1, TComplex<TYPE> &x2, TComplex<TYPE> &x3);
// Find solutions of a * x * x * x + b * x * x + c * x + d = 0 equation and store them in x1, x2, and x3. Return number of found solutions including complex ones. Return 0(if a, b, and c are zero), 2 or 3. Tolerance is used to compare a, b, and c with zero
template<class TYPE>
typename std::enable_if<std::is_floating_point<TYPE>::value, int>::type
SolveEquation3n(const TYPE a, const TYPE b, const TYPE c, const TYPE d, TComplex<TYPE> &x1, TComplex<TYPE> &x2, TComplex<TYPE> &x3, const TYPE tolerance);
Namespace: | nitisa::math |
Include: | Nitisa/Modules/Math/Equation.h |