Package math.differentialcalculus
Class Formula
java.lang.Object
math.differentialcalculus.Formula
public class Formula
extends java.lang.Object
- Author:
- GBEMIRO Objects of this class represent name-value pairs useful in
the simplification of variables on the expression. Portions of a multi
bracketed expression are the values and are assigned names. Any 2 different
portions having the same content must be assigned the same name.
The class must employ techniques such that any 2 or more objects of this
class that have the same tokens stored in the
expressionmust have the samenameWhen employing objects of this class, strip the expression of the opening and closing brackets, in fact, no bracket must be found in the expression.
-
Constructor Summary
Constructors Constructor Description Formula(java.lang.String name, java.util.List<java.lang.String> data) -
Method Summary
Modifier and Type Method Description static booleanapproxEquals(double num1, double num2)java.util.List<java.lang.String>getData()doublegetFactor(Formula formula)java.lang.StringgetName()java.util.ArrayList<java.lang.String>getVariables()booleanhasSameVariables(Formula formula)booleanisEquivalentTo(Formula formula)This method compares two Formula objects to see if they are mathematically equivalent.voidsetData(java.util.List<java.lang.String> data)voidsetName(java.lang.String name)static voidsimplify(java.util.List<java.lang.String> list)Simplifies a Single-Bracket-Pair algebraic expressions's tokens.java.lang.StringtoString()
-
Constructor Details
-
Formula
public Formula(java.lang.String name, java.util.List<java.lang.String> data)
-
-
Method Details
-
setData
public void setData(java.util.List<java.lang.String> data) -
getData
public java.util.List<java.lang.String> getData() -
approxEquals
public static boolean approxEquals(double num1, double num2) -
setName
public void setName(java.lang.String name) -
getName
public java.lang.String getName() -
getVariables
public java.util.ArrayList<java.lang.String> 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/formulaand 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.
-
simplify
public static void simplify(java.util.List<java.lang.String> list)Simplifies a Single-Bracket-Pair algebraic expressions's tokens.- Parameters:
list- An ArrayList of tokens of an algebraic expressions.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-