Laguerre class
Laguerre's method can be used to numerically solve polynomials in the form
P(x) = 0
where P(x)
is a given polynomial. This method requires an initial
guess x0 to start finding the roots.
Empirical evidence has shown that convergence failure is extremely rare so this is a good root finding algorithm for polynomials.
The biggest advantage of Laguerre's method is that it will converge regardless the value of the initial guess. For this reason, the initialGuess parameter of this class is optional (it's defaulted to zero).
Constructors
-
Laguerre({required List<
Complex> coefficients, Complex initialGuess = const Complex.zero(), double precision = 1.0e-10, int maxSteps = 1000}) - Instantiates a new object to find all the roots of a polynomial equation using Laguerre's method. The polynomial can have both complex (Complex) and real (double) values.
-
Laguerre.realEquation({required List<
double> coefficients, Complex initialGuess = const Complex.zero(), double precision = 1.0e-10, int maxSteps = 8000}) - Instantiates a new object to find all the roots of a polynomial equation using Laguerre's method. The polynomial can have both complex (Complex) and real (double) values.
Properties
-
coefficients
↔ List<
Complex> -
An unmodifiable list with the coefficients of the polynomial.
latefinalinherited
- degree → int
-
The degree of the polynomial.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setteroverride
- initialGuess → Complex
-
The initial guess from which the algorithm has to start finding the roots.
It's defaulted to Complex.zero() because the method will work regardless
the value of the initial guess.
final
- isRealEquation → bool
-
Determines whether the polynomial is real or not.
no setterinherited
- isValid → bool
-
A polynomial equation is valid if the coefficient associated to the
variable of highest degree is different from zero. In other words, the
polynomial is valid if
a
is different from zero.no setterinherited - maxSteps → int
-
The maximum steps to be made by the algorithm.
final
- precision → double
-
The accuracy of the algorithm.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
coefficient(
int degree) → Complex? -
Returns the coefficient of the polynomial whose degree is
degree
. For example:inherited -
copyWith(
{List< Complex> ? coefficients, Complex? initialGuess, double? precision, int? maxSteps}) → Laguerre - Creates a deep copy of this object with the given fields replaced with the new values.
-
derivative(
) → Algebraic -
The derivative of the polynomial.
override
-
discriminant(
) → Complex -
The discriminant of the algebraic equation if it exists.
override
-
evaluateIntegralOn(
double lower, double upper) → Complex -
Integrates the polynomial between
lower
andupper
and computes the result.inherited -
evaluateOn(
Complex x) → Complex -
Evaluates the polynomial on the specified complex number
x
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
realEvaluateOn(
double x) → Complex -
Evaluates the polynomial on the specified real number
x
.inherited -
solutions(
) → List< Complex> -
Calculates the roots (the solutions) of the equation.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
toStringWithFractions(
) → String -
Returns a string representation of the polynomial where the coefficients
are converted into their fractional representation.
inherited
Operators
-
operator *(
Algebraic other) → Algebraic -
The product of two polynomials is performed by multiplying the corresponding
coefficients of the polynomials. The degrees of the two polynomials don't
need to be the same so you can multiply a Constant with a Laguerre for
example.
inherited
-
operator +(
Algebraic other) → Algebraic -
The addition of two polynomials is performed by adding the corresponding
coefficients. The degrees of the two polynomials don't need to be the same
so you can sum a Cubic with a Linear for example.
inherited
-
operator -(
Algebraic other) → Algebraic -
The difference of two polynomials is performed by subtracting the
corresponding coefficients. The degrees of the two polynomials don't need
to be the same so you can subtract a Quadratic and a Quartic for example.
inherited
-
operator /(
Algebraic other) → AlgebraicDivision -
This operator divides a polynomial by another polynomial of the same or
lower degree.
inherited
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator [](
int index) → Complex -
Returns the coefficient of the polynomial at the given
index
position. For example:inherited -
operator unary-(
) → Algebraic -
The 'negation' operator changes the sign of every coefficient of the
polynomial. For example:
inherited