Package functions.commutative
Class Sum
Object
- All Implemented Interfaces:
Differentiable
,Evaluable
,Outputable
,Simplifiable
,Comparable<GeneralFunction>
,Iterable<GeneralFunction>
public class Sum extends CommutativeFunction
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Sum(GeneralFunction... functions)
Constructs a newSum
-
Method Summary
Modifier and Type Method Description Sum
clone()
Returns a clone of thisGeneralFunction
Sum
combineLikeTerms()
Returns aSum
where like terms are added together.double
evaluate(Map<String,Double> variableValues)
Evaluates aGeneralFunction
at a point denoted by aMap
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
double
operate(double a, double b)
Performs the operation of thisCommutativeFunction
on the two inputsSum
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
compareSelf, equalsFunction, getFunctions, hashCode, iterator, simplify, 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
-
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
-
combineLikeTerms
Returns aSum
where like terms are added together. Ex:2x+x=3x
- Returns:
- a
Sum
where like terms are added together
-
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
-