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 Sumclone()Returns a clone of thisGeneralFunctionSumcombineLikeTerms()Returns aSumwhere like terms are added together.doubleevaluate(Map<String,Double> variableValues)Evaluates aGeneralFunctionat a point denoted by aMapGeneralFunctiongetDerivative(String varID)Returns the derivative of aGeneralFunctionwith respect to a variable.doublegetIdentityValue()Returns the identity of thisCommutativeFunction, such as 0 for + or gcd and 1 for * or lcmCommutativeFunctiongetInstance(GeneralFunction... functions)Returns an instance of thisGeneralFunctionprotected Collector<CharSequence,?,String>getJoiningCollector()Returns a collector used to create thetoStringof theCommutativeFunctiondoubleoperate(double a, double b)Performs the operation of thisCommutativeFunctionon the two inputsSumsimplifyInternal()Simplifies thisCommutativeFunctionusing all methods that are guaranteed to return aCommutativeFunctionof the same typeOutputFunctiontoOutputFunction()Converts this function into anOutputFunctionfor use in string conversionMethods inherited from class CommutativeFunction
compareSelf, equalsFunction, getFunctions, hashCode, iterator, simplify, simplifyConstants, simplifyElements, simplifyIdentity, simplifyPull, simplifyTrivialElement, substituteAll, toStringMethods 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:EvaluableEvaluates aGeneralFunctionat a point denoted by aMap- Parameters:
variableValues- the values of the variables in theGeneralFunctionat the point- Returns:
- the value of the
GeneralFunctionat the point
-
getDerivative
Description copied from interface:DifferentiableReturns the derivative of aGeneralFunctionwith 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:CommutativeFunctionReturns an instance of thisGeneralFunction- Specified by:
getInstancein classCommutativeFunction- Parameters:
functions- theGeneralFunctions that will be acted on- Returns:
- an instance of this
GeneralFunction
-
clone
Description copied from class:GeneralFunctionReturns a clone of thisGeneralFunction- Specified by:
clonein classGeneralFunction- Returns:
- a clone of this function
-
getJoiningCollector
protected Collector<CharSequence,?,String> getJoiningCollector()Description copied from class:CommutativeFunctionReturns a collector used to create thetoStringof theCommutativeFunction- Overrides:
getJoiningCollectorin classCommutativeFunction- Returns:
- a joining collector
-
simplifyInternal
Description copied from class:CommutativeFunctionSimplifies thisCommutativeFunctionusing all methods that are guaranteed to return aCommutativeFunctionof the same type- Overrides:
simplifyInternalin classCommutativeFunction- Returns:
- the simplified
CommutativeFunction
-
combineLikeTerms
Returns aSumwhere like terms are added together. Ex:2x+x=3x- Returns:
- a
Sumwhere like terms are added together
-
getIdentityValue
public double getIdentityValue()Description copied from class:CommutativeFunctionReturns the identity of thisCommutativeFunction, such as 0 for + or gcd and 1 for * or lcm- Specified by:
getIdentityValuein classCommutativeFunction- Returns:
- the identity of this
CommutativeFunction
-
operate
public double operate(double a, double b)Description copied from class:CommutativeFunctionPerforms the operation of thisCommutativeFunctionon the two inputs- Specified by:
operatein classCommutativeFunction- Parameters:
a- the first inputb- the second input- Returns:
- the operation applied to the inputs
-
toOutputFunction
Description copied from interface:OutputableConverts this function into anOutputFunctionfor use in string conversion- Specified by:
toOutputFunctionin interfaceOutputable- Overrides:
toOutputFunctionin classCommutativeFunction- Returns:
- this function as an
OutputFunction
-