DurandKerner class final

The Durand–Kerner method, also known as Weierstrass method, is a root finding algorithm for solving polynomial equations. With this class, you can find all roots of a polynomial of any degree.

This is the preferred approach:

  • when the polynomial degree is 5 or higher, use DurandKerner;
  • when the polynomial degree is 4, use Quartic;
  • when the polynomial degree is 3, use Cubic;
  • when the polynomial degree is 2, use Quadratic;
  • when the polynomial degree is 1, use Linear.

The algorithm requires an initial set of values to find the roots. This implementation generates some random values if the user doesn't provide initial points to the algorithm.

Note that this algorithm does NOT always converge. To be more clear, it is NOT true that for every polynomial, the set of initial vectors that eventually converges to roots is open and dense.

Inheritance

Constructors

DurandKerner({required List<Complex> coefficients, List<Complex> initialGuess = const [], double precision = 1.0e-10, int maxSteps = 2000})
Creates a new object that finds all the roots of a polynomial equation using the Durand-Kerner algorithm. The polynomial can have both complex (Complex) and real (double) values.
DurandKerner.realEquation({required List<double> coefficients, List<Complex> initialGuess = const [], double precision = 1.0e-10, int maxSteps = 2000})
Creates a new object that finds all the roots of a polynomial equation using the Durand-Kerner algorithm. The polynomial can only have real (double) values.

Properties

coefficients List<Complex>
The list with the polynomial coefficients.
finalinherited
degree int
The degree of the polynomial.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
initialGuess List<Complex>
The initial guess from which the algorithm has to start finding the roots.
final
isRealEquation bool
Determines whether the polynomial is real or not.
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
complexHypot(Complex x, Complex y) Complex
Computes sqrt(x^2 + y^2) without under/overflow.
inherited
copyWith({List<Complex>? coefficients, List<Complex>? initialGuess, double? precision, int? maxSteps}) DurandKerner
Creates a deep copy of this object and replaces (if non-null) the given values with the old ones.
derivative() Algebraic
The derivative of the polynomial.
override
discriminant() Complex
The polynomial discriminant, if it exists.
override
evaluateIntegralOn(double lower, double upper) Complex
Evaluates the integral of the the polynomial between lower and upper.
inherited
evaluateOn(Complex x) Complex
Evaluates the polynomial on the given x value.
inherited
hypot(double x, double y) double
Computes sqrt(x^2 + y^2) without under/overflow.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
realEvaluateOn(double x) Complex
Evaluates the polynomial on the given decimal x value.
inherited
solutions() List<Complex>
Finds the roots (the solutions) of the associated P(x) = 0 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.
inherited
operator +(Algebraic other) Algebraic
The sum of two polynomials is performed by adding the corresponding coefficients.
inherited
operator -(Algebraic other) Algebraic
The difference of two polynomials is performed by subtracting the corresponding coefficients.
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