Class Formula

java.lang.Object
com.github.gbenroscience.math.differentialcalculus.Formula

public class Formula extends 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 expression must have the same name When 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 Details

  • Method Details

    • setData

      public void setData(List<String> data)
    • getData

      public List<String> getData()
    • approxEquals

      public static boolean approxEquals(double num1, double num2)
    • setName

      public void setName(String name)
    • getName

      public String getName()
    • getVariables

      public ArrayList<String> getVariables()
      Returns:
      an ArrayList containing all the variable names found in this Formula object.
    • hasSameVariables

      public boolean hasSameVariables(Formula formula)
      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

      public double getFactor(Formula formula)
      Parameters:
      formula - The Formula to express as a scalar factor of this Formula...Evaluates this/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

      public boolean isEquivalentTo(Formula formula)
      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(List<String> list)
      Simplifies a Single-Bracket-Pair algebraic expressions's tokens.
      Parameters:
      list - An ArrayList of tokens of an algebraic expressions.
    • toString

      public String toString()
      Overrides:
      toString in class Object