Algebraic.fromReal constructor
Returns an Algebraic instance according with the number of coefficients
passed. In particular:
- if length is 1, a Constant object is returned;
- if length is 2, a Linear object is returned;
- if length is 3, a Quadratic object is returned;
- if length is 4, a Cubic object is returned;
- if length is 5, a Quartic object is returned;
- if length is 6 or higher, a Laguerre object is returned.
For example, if the length of coefficients
were 3 it would mean that
you're trying to solve a quadratic equation (because a quadratic has
exactly 3 coefficients).
final linear = Algebraic.fromReal(const [0.5, 6]);
In the above example, linear
is of type Linear because the given
coefficients represent the 0.5x + 6 = 0
equation.
Use this method when the coefficients are all real numbers. If there were complex numbers as well, use the Algebraic.from(coefficients) instead.
Implementation
factory Algebraic.fromReal(List<double> coefficients) =>
Algebraic.from(coefficients.map((c) => Complex.fromReal(c)).toList());