public class Polynomial extends AbstractUnivariateRealFunction implements Ring<Polynomial>, VectorSpace<Polynomial,Real>
UnivariateRealFunction
that represents a finite length expression constructed from variables and constants,
using the operations of addition, subtraction, multiplication, and constant non-negative whole number exponents.
Specifically, it has the form
\[
p(x) = a_0x^n + a_1x^{n-1} + ... + a_{n-1}x + a_n
\]
This implementation is immutable.Function.EvaluationException
Modifier and Type | Field and Description |
---|---|
static Polynomial |
ONE
a polynomial representing 1
|
static Polynomial |
ZERO
a polynomial representing 0
|
Constructor and Description |
---|
Polynomial(double... coefficients)
Construct a polynomial from an array of coefficients.
|
Polynomial(Polynomial that)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
Polynomial |
add(Polynomial that)
+ : G × G → G
|
int |
degree()
Get the degree of this polynomial.
|
boolean |
equals(Object obj) |
Complex |
evaluate(Complex z)
Evaluate this polynomial at x.
|
double |
evaluate(double x)
Evaluate this polynomial at x.
|
Complex |
evaluate(Number x)
Evaluate this polynomial at x.
|
double |
getCoefficient(int i)
Get an-i, the coefficient of xn-i.
|
double[] |
getCoefficients()
Get a copy of the polynomial coefficients.
|
Polynomial |
getNormalization()
Get the normalized version of this polynomial so the leading coefficient is 1.
|
int |
hashCode() |
Polynomial |
minus(Polynomial that)
- : G × G → G
The operation "-" is not in the definition of of an additive group but can be deduced.
|
Polynomial |
multiply(Polynomial that)
× : G × G → G
|
Polynomial |
ONE()
The multiplicative element 1 in the group such that for any elements a in the group,
the equation 1 × a = a × 1 = a holds.
|
Polynomial |
opposite()
For each a in G, there exists an element b in G such that
a + b = b + a = 0.
|
Polynomial |
pow(int n) |
Polynomial |
scaled(double c) |
Polynomial |
scaled(Real c)
× : F × V → V
The result of applying this function to a scalar, c, in F and v in V is denoted cv.
|
String |
toString() |
Polynomial |
ZERO()
The additive element 0 in the group, such that for all elements a in the group,
the equation 0 + a = a + 0 = a holds.
|
evaluate
dimensionOfDomain, dimensionOfRange
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
dimensionOfDomain, dimensionOfRange
public static final Polynomial ZERO
public static final Polynomial ONE
public Polynomial(double... coefficients)
new Polynomial(1, -2, 3, 2)
creates an instance of Polynomial
representing x3 - 2x2 + 3x + 2.coefficients
- the polynomial coefficientspublic Polynomial(Polynomial that)
that
- a polynomialpublic int degree()
public double[] getCoefficients()
coefficients[i]
is the coefficient of xn-i, where n is the polynomial degree.
Specifically, coefficients[0]
is the leading coefficient and coefficients[n]
the constant term.public double getCoefficient(int i)
i
- the i-th coefficient in this polynomial, counting from 0getCoefficients()
public Polynomial getNormalization()
public Complex evaluate(Number x)
x
- the argumentpublic double evaluate(double x)
evaluate
in interface UnivariateRealFunction
x
- the argumentpublic Complex evaluate(Complex z)
z
- the argumentpublic Polynomial add(Polynomial that)
AbelianGroup
add
in interface AbelianGroup<Polynomial>
that
- the object to be addedpublic Polynomial minus(Polynomial that)
AbelianGroup
this.add(that.opposite())
.minus
in interface AbelianGroup<Polynomial>
that
- the object to be subtracted (subtrahend)public Polynomial multiply(Polynomial that)
Monoid
multiply
in interface Monoid<Polynomial>
that
- the multiplicandpublic Polynomial pow(int n)
public Polynomial scaled(Real c)
VectorSpace
scaled
in interface VectorSpace<Polynomial,Real>
c
- a multiplierpublic Polynomial scaled(double c)
public Polynomial opposite()
AbelianGroup
this.add(this.opposite()) == this.ZERO
opposite
in interface AbelianGroup<Polynomial>
public Polynomial ZERO()
AbelianGroup
ZERO
in interface AbelianGroup<Polynomial>
public Polynomial ONE()
Monoid
ONE
in interface Monoid<Polynomial>
Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.