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 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 Summary

    Constructors 
    Constructor Description
    Formula​(java.lang.String name, java.util.List<java.lang.String> data)  
  • Method Summary

    Modifier and Type Method Description
    static boolean approxEquals​(double num1, double num2)  
    java.util.List<java.lang.String> getData()  
    double getFactor​(Formula formula)  
    java.lang.String getName()  
    java.util.ArrayList<java.lang.String> getVariables()  
    boolean hasSameVariables​(Formula formula)  
    boolean isEquivalentTo​(Formula formula)
    This method compares two Formula objects to see if they are mathematically equivalent.
    void setData​(java.util.List<java.lang.String> data)  
    void setName​(java.lang.String name)  
    static void simplify​(java.util.List<java.lang.String> list)
    Simplifies a Single-Bracket-Pair algebraic expressions's tokens.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      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​(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:
      toString in class java.lang.Object