Package math.differentialcalculus
Class Formula
java.lang.Object
math.differentialcalculus.Formula
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionThe portion of the main expression stored by the object..private String
The name assigned to the object.Stores all the exponents(which are usually lists of compound tokens as the values in this map, the keys are the unique names used to replace them as the power of the token. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
approxEquals
(double num1, double num2) getData()
double
getName()
boolean
hasSameVariables
(Formula formula) boolean
isEquivalentTo
(Formula formula) This method compares two Formula objects to see if they are mathematically equivalent.void
void
static void
Simplifies a Single-Bracket-Pair algebraic expressions's tokens.(package private) static void
simplifyCompoundTokens
(List<String> list) A Compound token is simply used to describe a group of tokens found between 2 +|- and +|- symbols or before a +|- symbol(at the beginning of the parent list before any +|- has been encountered) or at the end of the parent list after all +|- have been passed.toString()
-
Field Details
-
name
The name assigned to the object. -
data
The portion of the main expression stored by the object.. usually an SBP. -
tokenExponentMap
Stores all the exponents(which are usually lists of compound tokens as the values in this map, the keys are the unique names used to replace them as the power of the token. e.g if x^(2+3*x+4*y) is scanned, we get x,^,(,2,+,3,*,x,+,4,*,y,) the sublist in brackets is stored as a list in thetokenExponentMap
and its key is the name used to store it. This name is auto-generated and used to replace the sub-list that is in brackets, the brackets included. It is also used as the key in this map. E.g. if the name chosen is formula_1 then the key to the map is formula_1, and its value is that sub-list.
-
-
Constructor Details
-
Formula
-
-
Method Details
-
setData
-
getData
-
approxEquals
public static boolean approxEquals(double num1, double num2) -
setName
-
getName
-
getVariables
- Returns:
- an ArrayList containing all the variable names found in this Formula object.
-
hasSameVariables
- Parameters:
formula
- The Formula object that we are comparing this Formula object with.- Returns:
- true if both objects have no variables at all, or if both objects have exactly the same number and the same set of variable names.
-
getFactor
- Parameters:
formula
- The Formula to express as a scalar factor of this Formula...Evaluatesthis
/formula
and returns true if the result will always be a constant and Nan if otherwise.- Returns:
- a constant which is the ratio of this Formula and the parameter Formula and returns Nan if not possible.
-
isEquivalentTo
This method compares two Formula objects to see if they are mathematically equivalent.- Parameters:
formula
- The Formula object to be compared with this Formula.- Returns:
- true if both objects will always evaluate to a common value.
-
simplifyCompoundTokens
A Compound token is simply used to describe a group of tokens found between 2 +|- and +|- symbols or before a +|- symbol(at the beginning of the parent list before any +|- has been encountered) or at the end of the parent list after all +|- have been passed. They typically never include any + or - symbol- Parameters:
list
- A group of tokens that do not contain any +|- but represent a mathematically correct expression.. e.g. 2,*,x,*,x e.t.c.
-
simplify
Simplifies a Single-Bracket-Pair algebraic expressions's tokens.- Parameters:
list
- An ArrayList of tokens of an algebraic expressions.
-
toString
-