Find solutions for x2 + ax + b = 0
or ax2 + bx + c = 0
equation where a
, b
, and c
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 + ax + b = 0 equation and store them in x1 and x2. Return number of found solutions including complex ones. Return either 1 or 2
template<class TYPE>
typename std::enable_if<std::is_floating_point<TYPE>::value, int>::type
SolveEquation2n(const TYPE a, const TYPE b, TComplex<TYPE> &x1, TComplex<TYPE> &x2);
// Find solutions of a * x * x + bx + c = 0 equation and store them in x1 and x2. Return number of found solutions including complex ones. Return 0(if both a and b are zero), 1 or 2. Tolerance is used to compare a and b with zero
template<class TYPE>
typename std::enable_if<std::is_floating_point<TYPE>::value, int>::type
SolveEquation2n(const TYPE a, const TYPE b, const TYPE c, TComplex<TYPE> &x1, TComplex<TYPE> &x2, const TYPE tolerance);
Namespace: | nitisa::math |
Include: | Nitisa/Modules/Math/Equation.h |