Package functions.commutative
Class Product
Object
GeneralFunction
CommutativeFunction
Product
- All Implemented Interfaces:
Differentiable
,Evaluable
,Outputable
,Simplifiable
,Comparable<GeneralFunction>
,Iterable<GeneralFunction>
public class Product extends CommutativeFunction
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Product(GeneralFunction... functions)
Constructs a newProduct
-
Method Summary
Modifier and Type Method Description Product
addExponents()
IfCommutativeFunction.functions
contains multiple functions that are equal to each other, including the bases ofPow
s, then the exponents are added and the terms are combined.Product
clone()
Returns a clone of thisGeneralFunction
int
compareSelf(GeneralFunction that)
Used internally for comparing two functions of the same exact typeGeneralFunction
distributeAll()
If one element of the product is aSum
, distributes the other contents of the product onto the sum.double
evaluate(Map<String,Double> variableValues)
Evaluates aGeneralFunction
at a point denoted by aMap
Product
fixNullIntegrals()
Turns constructs like a null-respect integral times\dx
into an integral with respect to'x'
GeneralFunction
getDerivative(String varID)
Returns the derivative of aGeneralFunction
with respect to a variable.double
getIdentityValue()
Returns the identity of thisCommutativeFunction
, such as 0 for + or gcd and 1 for * or lcmCommutativeFunction
getInstance(GeneralFunction... functions)
Returns an instance of thisGeneralFunction
protected Collector<CharSequence,?,String>
getJoiningCollector()
Returns a collector used to create thetoString
of theCommutativeFunction
boolean
isTimesZero()
double
operate(double a, double b)
Performs the operation of thisCommutativeFunction
on the two inputsGeneralFunction
simplify()
Returns thisGeneralFunction
, simplifiedProduct
simplifyInternal()
Simplifies thisCommutativeFunction
using all methods that are guaranteed to return aCommutativeFunction
of the same typeOutputFunction
toOutputFunction()
Converts this function into anOutputFunction
for use in string conversionMethods inherited from class CommutativeFunction
equalsFunction, getFunctions, hashCode, iterator, simplifyConstants, simplifyElements, simplifyIdentity, simplifyPull, simplifyTrivialElement, substituteAll, toString
Methods inherited from class GeneralFunction
compareTo, derivativeAt, equals, equalsSimplified, getNthDerivative, getSimplifiedDerivative, substituteVariables
-
Constructor Details
-
Method Details
-
evaluate
public double evaluate(Map<String,Double> variableValues)Description copied from interface:Evaluable
Evaluates aGeneralFunction
at a point denoted by aMap
- Parameters:
variableValues
- the values of the variables in theGeneralFunction
at the point- Returns:
- the value of the
GeneralFunction
at the point
-
getDerivative
Description copied from interface:Differentiable
Returns the derivative of aGeneralFunction
with respect to a variable. Should not be used in general;GeneralFunction.getSimplifiedDerivative(java.lang.String)
is strongly preferred.- Parameters:
varID
- the ID of the variable that is differentiated against- Returns:
- the derivative of the function with respect to
varID
-
getInstance
Description copied from class:CommutativeFunction
Returns an instance of thisGeneralFunction
- Specified by:
getInstance
in classCommutativeFunction
- Parameters:
functions
- theGeneralFunction
s that will be acted on- Returns:
- an instance of this
GeneralFunction
-
clone
Description copied from class:GeneralFunction
Returns a clone of thisGeneralFunction
- Specified by:
clone
in classGeneralFunction
- Returns:
- a clone of this function
-
getJoiningCollector
protected Collector<CharSequence,?,String> getJoiningCollector()Description copied from class:CommutativeFunction
Returns a collector used to create thetoString
of theCommutativeFunction
- Overrides:
getJoiningCollector
in classCommutativeFunction
- Returns:
- a joining collector
-
compareSelf
Description copied from class:GeneralFunction
Used internally for comparing two functions of the same exact type- Overrides:
compareSelf
in classCommutativeFunction
- Parameters:
that
- theGeneralFunction
that this is compared against- Returns:
- the comparison
-
simplify
Description copied from interface:Simplifiable
Returns thisGeneralFunction
, simplified- Specified by:
simplify
in interfaceSimplifiable
- Overrides:
simplify
in classCommutativeFunction
- Returns:
- the simplified function
-
simplifyInternal
Description copied from class:CommutativeFunction
Simplifies thisCommutativeFunction
using all methods that are guaranteed to return aCommutativeFunction
of the same type- Overrides:
simplifyInternal
in classCommutativeFunction
- Returns:
- the simplified
CommutativeFunction
-
isTimesZero
public boolean isTimesZero() -
addExponents
IfCommutativeFunction.functions
contains multiple functions that are equal to each other, including the bases ofPow
s, then the exponents are added and the terms are combined. Ex:sin(x)*(sin(x))^2
becomes(sin(x))^3
- Returns:
- A new
Product
with exponents combined as specified above
-
fixNullIntegrals
Turns constructs like a null-respect integral times\dx
into an integral with respect to'x'
- Returns:
- this function with null-integrals fixed, if possible
-
distributeAll
If one element of the product is aSum
, distributes the other contents of the product onto the sum. Example:sin(y)*(x+2) = x*sin(y) + 2*sin(y)
- Returns:
- this function with multiplication and addition distributed if possible
-
getIdentityValue
public double getIdentityValue()Description copied from class:CommutativeFunction
Returns the identity of thisCommutativeFunction
, such as 0 for + or gcd and 1 for * or lcm- Specified by:
getIdentityValue
in classCommutativeFunction
- Returns:
- the identity of this
CommutativeFunction
-
operate
public double operate(double a, double b)Description copied from class:CommutativeFunction
Performs the operation of thisCommutativeFunction
on the two inputs- Specified by:
operate
in classCommutativeFunction
- Parameters:
a
- the first inputb
- the second input- Returns:
- the operation applied to the inputs
-
toOutputFunction
Description copied from interface:Outputable
Converts this function into anOutputFunction
for use in string conversion- Specified by:
toOutputFunction
in interfaceOutputable
- Overrides:
toOutputFunction
in classCommutativeFunction
- Returns:
- this function as an
OutputFunction
-