Cubic class
Concrete implementation of Algebraic that represents a third degree
polynomial equation in the form ax^3 + bx^2 + cx + d = 0
.
This equation has exactly 3 solutions:
- 3 distinct real roots and 0 complex roots
- 3 real roots (some of them are equal) and 0 complex roots
- 1 real root and 2 complex conjugate roots
The above cases depend on the value of the discriminant.
Constructors
- Cubic.new({Complex a = const Complex.fromReal(1), Complex b = const Complex.zero(), Complex c = const Complex.zero(), Complex d = const Complex.zero()})
- These are examples of cubic equations, where the coefficient with the highest degree goes first:
- Cubic.realEquation({double a = 1, double b = 0, double c = 0, double d = 0})
-
The only coefficient of the polynomial is represented by a double
(real) number
a
.
Properties
- a → Complex
-
The first coefficient of the equation in the form
f(x) = ax^3 + bx^2 + cx + d = 0
no setter
- b → Complex
-
The second coefficient of the equation in the form
f(x) = ax^3 + bx^2 + cx + d = 0
no setter
- c → Complex
-
The third coefficient of the equation in the form
f(x) = ax^3 + bx^2 + cx + d = 0
no setter
-
coefficients
→ UnmodifiableListView<
Complex> -
An unmodifiable list with the coefficients of the polynomial.
finalinherited
- d → Complex
-
The fourth coefficient of the equation in the form
f(x) = ax^3 + bx^2 + cx + d = 0
no setter
- degree → int
-
The degree of the polynomial.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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 - 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(
{Complex? a, Complex? b, Complex? c, Complex? d}) → Cubic - 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 given 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 given 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 DurandKerner 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.
inherited
-
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