Class PolynomialExpression

java.lang.Object
parser.MathExpression
parser.PolynomialExpression
All Implemented Interfaces:
Savable, Solvable, Serializable

public class PolynomialExpression extends MathExpression
See Also:
  • Field Details

    • DOUBLE_PRECISION

      public static final int DOUBLE_PRECISION
      Solves the Polynomial with normal double precision....about 16d.p.
      See Also:
    • BIGDECIMAL_PRECISION

      public static final int BIGDECIMAL_PRECISION
      Solves the Polynomial with BigDecimal precision....about 16d.p.
      See Also:
    • precision

      private int precision
      Used to select what mode to operate objects of this class...whether DOUBLE_PRECISION or BIGDECIMAL_PRECISION.
  • Constructor Details

    • PolynomialExpression

      public PolynomialExpression(String expression, int precision)
      Parameters:
      expression - A valid polynomial expression, having powers of the variable as only non-negative integers.
  • Method Details

    • setPrecision

      public void setPrecision(int precision)
      Parameters:
      precision - The precision to use. If set to any value other than 1 (DOUBLE_PRECISION) or 2 (BIGDECIMAL_PRECISION), it defaults to DOUBLE_PRECISION
    • getPrecision

      public int getPrecision()
    • solve

      public List<String> solve(List<String> list)
      Description copied from class: MathExpression
      used by the main parser solve to figure out SBP portions of a multi-bracketed expression (MBP)
      Overrides:
      solve in class MathExpression
      Parameters:
      list - a list of scanner tokens of a maths expression
      Returns:
      the solution to a SBP maths expression
    • doublePrecisionSolve

      public List<String> doublePrecisionSolve(List<String> list)
      Used by the main parser solve to figure out SBP portions of a multi-bracketed expression (MBP)
      Parameters:
      list - a list of scanner tokens of a maths expression
      Returns:
      the solution to a SBP maths expression. The precision returned here is that of double numbers, namely about 16d.p
    • bigDecimalPrecisionSolve

      public List<String> bigDecimalPrecisionSolve(List<String> list)
      used by the main parser solve to figure out SBP portions of a multi-bracketed expression (MBP)
      Parameters:
      list - a list of scanner tokens of a maths expression
      Returns:
      the solution to a SBP maths expression
    • main

      public static void main(String[] args)