\n\n\n\nPolynomial\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n
\n
\n
\n\n\n\n
\n
org.jscience.mathematics.function
\n

Class Polynomial<R extends Ring<R>>

\n
\n
\n
\n
\n
\n
• \n
\n
All Implemented Interfaces:
\n
Serializable, javolution.lang.Immutable, javolution.lang.Realtime, javolution.lang.ValueType, GroupAdditive<Polynomial<R>>, Ring<Polynomial<R>>, Structure<Polynomial<R>>
\n
\n
\n
Direct Known Subclasses:
\n
Constant
\n
\n
\n
\n
public class Polynomial<R extends Ring<R>>\nextends Function<R,R>\nimplements Ring<Polynomial<R>>
\n

This class represents a mathematical expression involving a sum of powers\n in one or more variables multiplied by \n coefficients (such as x\xc2\xb2 + x\xc2\xb7y + 3y\xc2\xb2).

\n \n

Polynomials are characterized by the type of variable they operate \n upon. For example:

\n           Variable<Amount<?>> varX = new Variable.Local<Amount<?>>("x");\n           Polynomial<Amount<?>> x = Polynomial.valueOf(Amount.valueOf(1, SI.METER), varX);\n     and\n           Variable<Complex> varX = new Variable.Local<Complex>("x");\n           Polynomial<Complex> x = Polynomial.valueOf(Complex.ONE, varX);
\n are two different polynomials, the first one operates on physical \n measures,\n whereas the second operates on \n complex numbers.

\n \n

Terms (others than ONE) having zero (additive identity) \n for coefficient are automatically removed.

\n
Serialized Form
\n
• \n
\n
\n
\n
\n
• \n\n
\n
• \n\n\n

Method Summary

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Methods
Modifier and TypeMethod and Description
<Z> Function<Z,R>compose(Function<Z,R> that)\n
Returns the composition of this function with the one specified.
\n
Polynomial<R>compose(Polynomial<R> that)\n
Returns the composition of this polynomial with the one specified.
\n
Polynomial<R>copy()\n
Returns a copy of this polynomial \n allocated \n by the calling thread (possibly on the stack).
\n
Polynomial<R>differentiate(Variable<R> v)\n
Returns the first derivative of this function with respect to \n the specified variable.
\n
booleanequals(Object obj)\n
Indicates if this function is equals to the specified object.
\n
Revaluate()\n
Evaluates this function using its variables current\n values.
\n
RgetCoefficient(Term term)\n
Returns the coefficient for the specified term.
\n
intgetOrder(Variable<R> v)\n
Returns the order of this polynomial for the specified variable.
\n
Set<Term>getTerms()\n
Returns the terms of this polynomial.
\n
List<Variable<R>>getVariables()\n
Returns a lexically ordered list of the variables (or arguments)\n for this function (empty list for constant functions).
\n
inthashCode()\n
Returns the hash code for this function (consistent with \n Function.equals(Object).
\n
Polynomial<R>integrate(Variable<R> v)\n
Returns an integral of this function with respect to \n the specified variable.
\n
Function<R,R>minus(Function<R,R> that)\n
Returns the difference of this function with the one specified.
\n
Polynomial<R>minus(Polynomial<R> that)\n
Returns the difference of two polynomials.
\n
Polynomial<R>opposite()\n
Returns the opposite of this polynomial.
\n
Function<R,R>plus(Function<R,R> that)\n
Returns the sum of this function with the one specified.
\n
Polynomial<R>plus(Polynomial<R> that)\n
Returns the sum of two polynomials.
\n
Polynomial<R>plus(R constantValue)\n
Returns the sum of this polynomial with a constant polynomial \n having the specified value (convenience method).
\n
Polynomial<R>pow(int n)\n
Returns this function raised at the specified exponent.
\n
Function<R,R>times(Function<R,R> that)\n
Returns the product of this function with the one specified.
\n
Polynomial<R>times(Polynomial<R> that)\n
Returns the product of two polynomials.
\n
Polynomial<R>times(R constantValue)\n
Returns the product of this polynomial with a constant polynomial \n having the specified value (convenience method).
\n
javolution.text.TexttoText()\n
Returns the textual representation of this real-time object\n (equivalent to toString except that the returned value\n can be allocated from the local context space).
\n
static <R extends Ring<R>>
Polynomial<R>
valueOf(R coefficient,\n Term term)\n
Returns a polynomial corresponding to the specified term\n with the specified coefficient multiplier.
\n
static <R extends Ring<R>>
Polynomial<R>
valueOf(R coefficient,\n Variable<R> variable)\n
Returns an univariate polynomial of degree one with the specified \n coefficient multiplier.
\n
\n\n\n
• \n
\n
• \n
\n
\n
\n
\n
• \n\n
\n
• \n\n\n

Method Detail

\n\n\n\n\n\n
\n
• \n

valueOf

\n
public static <R extends Ring<R>> Polynomial<R> valueOf(R coefficient,\n                                        Variable<R> variable)
\n
Returns an univariate polynomial of degree one with the specified \n coefficient multiplier.
\n
Parameters:
coefficient - the coefficient for the variable of degree 1.
variable - the variable for this polynomial.
\n
Returns:
valueOf(coefficient, Term.valueOf(variable, 1))
\n
• \n
\n\n\n\n\n\n
\n
• \n

valueOf

\n
public static <R extends Ring<R>> Polynomial<R> valueOf(R coefficient,\n                                        Term term)
\n
Returns a polynomial corresponding to the specified term\n with the specified coefficient multiplier.
\n
Parameters:
coefficient - the coefficient multiplier.
term - the term multiplicand.
\n
Returns:
coefficient * term
\n
• \n
\n\n\n\n
\n
• \n

getTerms

\n
public Set<Term> getTerms()
\n
Returns the terms of this polynomial.
\n
Returns:
this polynomial\'s terms.
\n
• \n
\n\n\n\n
\n
• \n

getCoefficient

\n
public final R getCoefficient(Term term)
\n
Returns the coefficient for the specified term.
\n
Parameters:
term - the term for which the coefficient is returned.
\n
Returns:
the coefficient for the specified term or null\n if this polynomial does not contain the specified term.
\n
• \n
\n\n\n\n
\n
• \n

getOrder

\n
public int getOrder(Variable<R> v)
\n
Returns the order of this polynomial for the specified variable.
\n
Returns:
the polynomial order relative to the specified variable.
\n
• \n
\n\n\n\n\n\n
\n
• \n

plus

\n
public Polynomial<R> plus(R constantValue)
\n
Returns the sum of this polynomial with a constant polynomial \n having the specified value (convenience method).
\n
Parameters:
constantValue - the value of the constant polynomial to add.
\n
Returns:
this + Constant.valueOf(constantValue)
\n
• \n
\n\n\n\n\n\n
\n
• \n

times

\n
public Polynomial<R> times(R constantValue)
\n
Returns the product of this polynomial with a constant polynomial \n having the specified value (convenience method).
\n
Parameters:
constantValue - the value of the constant polynomial to multiply.
\n
Returns:
this \xc2\xb7 Constant.valueOf(constantValue)
\n
• \n
\n\n\n\n\n\n\n\n\n\n\n\n
\n
• \n

minus

\n
public Polynomial<R> minus(Polynomial<R> that)
\n
Returns the difference of two polynomials.
\n
Parameters:
that - the polynomial being subtracted.
\n
Returns:
this - that
\n
• \n
\n\n\n\n
\n
• \n

times

\n
public Polynomial<R> times(Polynomial<R> that)
\n
Returns the product of two polynomials.
\n
\n
Specified by:
\n
times in interface Ring<Polynomial<R extends Ring<R>>>
\n
Parameters:
that - the polynomial multiplier.
\n
Returns:
this \xc2\xb7 that
\n
• \n
\n\n\n\n
\n
• \n

compose

\n
public Polynomial<R> compose(Polynomial<R> that)
\n
Returns the composition of this polynomial with the one specified.
\n
Parameters:
that - the polynomial for which the return value is passed as\n argument to this function.
\n
Returns:
the polynomial (this o that)
\n
Throws:
\n
FunctionException - if this function is not univariate.
\n
• \n
\n\n\n\n
\n
• \n

compose

\n
public <Z> Function<Z,R> compose(Function<Z,R> that)
\n
Description copied from class: Function
\n
Returns the composition of this function with the one specified.
\n
\n
Overrides:
\n
compose in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Parameters:
that - the function for which the return value is passed as\n argument to this function.
\n
Returns:
the function (this o that)
\n
• \n
\n\n\n\n\n\n\n\n\n\n\n\n
\n
• \n

plus

\n
public Function<R,R> plus(Function<R,R> that)
\n
Description copied from class: Function
\n
Returns the sum of this function with the one specified.
\n
\n
Overrides:
\n
plus in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Parameters:
that - the function to be added.
\n
Returns:
this + that.
\n
• \n
\n\n\n\n
\n
• \n

minus

\n
public Function<R,R> minus(Function<R,R> that)
\n
Description copied from class: Function
\n
Returns the difference of this function with the one specified.
\n
\n
Overrides:
\n
minus in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Parameters:
that - the function to be subtracted.
\n
Returns:
this - that.
\n
• \n
\n\n\n\n
\n
• \n

times

\n
public Function<R,R> times(Function<R,R> that)
\n
Description copied from class: Function
\n
Returns the product of this function with the one specified.
\n
\n
Overrides:
\n
times in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Parameters:
that - the function multiplier.
\n
Returns:
this \xc2\xb7 that.
\n
• \n
\n\n\n\n
\n
• \n

pow

\n
public Polynomial<R> pow(int n)
\n
Description copied from class: Function
\n
Returns this function raised at the specified exponent.
\n
\n
Overrides:
\n
pow in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Parameters:
n - the exponent.
\n
Returns:
thisn
\n
• \n
\n\n\n\n
\n
• \n

getVariables

\n
public List<Variable<R>> getVariables()
\n
Description copied from class: Function
\n
Returns a lexically ordered list of the variables (or arguments)\n for this function (empty list for constant functions).
\n
\n
Specified by:
\n
getVariables in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Returns:
this function current unset variables (sorted).
\n
• \n
\n\n\n\n
\n
• \n

evaluate

\n
public R evaluate()
\n
Description copied from class: Function
\n
Evaluates this function using its variables current\n values.
\n
\n
Specified by:
\n
evaluate in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Returns:
the evaluation of this function.
\n
• \n
\n\n\n\n
\n
• \n

equals

\n
public boolean equals(Object obj)
\n
Description copied from class: Function
\n
Indicates if this function is equals to the specified object.
\n
\n
Overrides:
\n
equals in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Parameters:
obj - the object to be compared with.
\n
Returns:
true if this function and the specified argument\n represent the same function; false otherwise.
\n
• \n
\n\n\n\n
\n
• \n

hashCode

\n
public int hashCode()
\n
Description copied from class: Function
\n
Returns the hash code for this function (consistent with \n Function.equals(Object).
\n
\n
Overrides:
\n
hashCode in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Returns:
this function hash code.
\n
• \n
\n\n\n\n
\n
• \n

toText

\n
public javolution.text.Text toText()
\n
Description copied from class: Function
\n
Returns the textual representation of this real-time object\n (equivalent to toString except that the returned value\n can be allocated from the local context space).
\n
\n
Specified by:
\n
toText in interface javolution.lang.Realtime
\n
Specified by:
\n
toText in class Function<R extends Ring<R>,R extends Ring<R>>
\n
Returns:
this object\'s textual representation.
\n
• \n
\n\n\n\n
\n
• \n

copy

\n
public Polynomial<R> copy()
\n
Returns a copy of this polynomial \n allocated \n by the calling thread (possibly on the stack).
\n
\n
Specified by:
\n
copy in interface javolution.lang.ValueType
\n
Returns:
an identical and independant copy of this polynomial.
\n
• \n
\n
• \n
\n
• \n
\n
\n
\n\n\n
\n\n\n\n\n
\n
\n
\n\n\n