Class Calculatte

java.lang.Object
io.github.derivasians.calculatte.Calculatte

public final class Calculatte extends Object
Contains all methods and properties to perform basic calculus operations.
Version:
0.2.0
Author:
Matthew Okashita, Joseph Benigno
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static double
    Represents how far the x-value should be offset left and right to find the left and right derivatives.
    static double
    Represents the largest difference between the left and right derivative before the derivative does not exist.
    static int
    Represents common known cross-sections types.
    static double
    Represents accuracy value for derivation calculations.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents common known cross-sections types.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static double
    Represents how far the x-value should be offset left and right to find the left and right limits.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static double
    Represents the largest difference between the left and right limit before the limit does not exist.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents accuracy value for integration calculations.
    static double
    All values less than to negativeInfinity will be rounded down to Double.NEGATIVE_INFINITY by Calculatte.round().
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static double
    All values greater than positiveInfinity will be rounded up to Double.POSITIVE_INFINITY by Calculatte.round().
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents common known cross-sections types.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
    static int
    Represents common known cross-sections types.
    static int
    Represents common known cross-sections types.
    static int
    Represents how many decimal places this variable's respective calculation(s) should be rounded too.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    crossSection​(double a, double b, Function integrand)
    Finds the volume of a known cross-section for a custom made cross-section formula.
    double
    crossSection​(double a, double b, Function functionTop, Function functionBottom, int type)
    Finds the volume of a known cross-section for any of the 5 common known cross-sections: square, equilateral triangle, isosceles triangle, right, triangle, and semicircle.
    double
    derivate​(double x, Function function)
    Finds the derivate of the function at point, x.
    double
    integrate​(double a, double b, Function function)
    Integrates the function from a to b using Simpson's rule.
    double
    leftDerivative​(double x, Function function)
    Finds the left derivate of the function at point, x.
    double
    leftLimit​(double x, Function function)
    Finds the left limit of function at point x.
    double
    leftRiemannSum​(double a, double b, Function function, int n)
    Finds the approximate area under the curve using the left Riemann sum rule with n rectangles.
    double
    limit​(double x, Function function)
    Finds the limit of function at point x.
    double
    midpointRule​(double a, double b, Function function, int n)
    Finds the approximate area under the curve using the midpoint rule with n rectangles.
    double
    polarArea​(double a, double b, Function r)
    Finds the area bounded by a polar function, r of theta, between two radian measures.
    double
    revolve​(double a, double b, double axis, Function functionTop, Function functionBottom)
    Finds the volume of revolution for the region bounded by functionTop, functionBottom, x = a, and x = b, about y = axis.
    double
    rightDerivative​(double x, Function function)
    Finds the right derivate of the function at point, x.
    double
    rightLimit​(double x, Function function)
    Finds the right limit of function at point x.
    double
    rightRiemannSum​(double a, double b, Function function, int n)
    Finds the approximate area under the curve using the right Riemann sum rule with n rectangles.
    double
    round​(double x, int decimalPlaces)
    Rounds doubles according to the IEEE 754 standard of rounding half to even.
    tangentLine​(double x, Function function)
    Finds the tangent line of function at point, x.
    double
    trapezoidalSum​(double a, double b, Function function, int n)
    Finds the approximate area under the curve using the trapezoidal sum rule with n trapezoids.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • integrationRoundingDecimalPlaces

      public static int integrationRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • derivationRoundingDecimalPlaces

      public static int derivationRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • leftRiemannSumRoundingDecimalPlaces

      public static int leftRiemannSumRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • rightRiemannSumRoundingDecimalPlaces

      public static int rightRiemannSumRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • midpointRuleRoundingDecimalPlaces

      public static int midpointRuleRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • trapezoidalSumRoundingDecimalPlaces

      public static int trapezoidalSumRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • revolutionRoundingDecimalPlaces

      public static int revolutionRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • crossSectionsRoundingDecimalPlaces

      public static int crossSectionsRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • limitRoundingDecimalPlaces

      public static int limitRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • leftLimitRoundingDecimalPlaces

      public static int leftLimitRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • rightLimitRoundingDecimalPlaces

      public static int rightLimitRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • polarAreaRoundingDecimalPlaces

      public static int polarAreaRoundingDecimalPlaces
      Represents how many decimal places this variable's respective calculation(s) should be rounded too. Only values returned by a method are rounded. Intermediate values within a method are never rounded, unless by another method; e.g., the revolve() method's calculations get rounded when the integral is taken with integrate() and once more when the final value is returned.

      Note: Setting any of these values to -1 will prevent that group of calculations from being rounded. This can be useful if you would prefer to use your own rounding method or none at all.

    • positiveInfinity

      public static double positiveInfinity

      All values greater than positiveInfinity will be rounded up to Double.POSITIVE_INFINITY by Calculatte.round().

      Note: Setting positiveInfinity to Double.MAX_VALUE will prevent rounding values up to Double.POSITIVE_INFINITY.

      See Also:
      round(double, int)
    • negativeInfinity

      public static double negativeInfinity

      All values less than to negativeInfinity will be rounded down to Double.NEGATIVE_INFINITY by Calculatte.round().

      Note: Setting negativeInfinity to Double.MIN_VALUE will prevent rounding values down to Double.NEGATIVE_INFINITY.

      See Also:
      round(double, int)
    • n

      public static int n
      Represents accuracy value for integration calculations. The larger the more accurate.
      See Also:
      integrate(double, double, Function)
    • h

      public static double h
      Represents accuracy value for derivation calculations. The smaller the more accurate.
      See Also:
      derivate(double, Function)
    • derivativeTolerance

      public static double derivativeTolerance
      Represents the largest difference between the left and right derivative before the derivative does not exist.
      See Also:
      derivate(double, Function)
    • derivativeOffset

      public static double derivativeOffset
      Represents how far the x-value should be offset left and right to find the left and right derivatives.
      See Also:
      leftDerivative(double, Function), rightDerivative(double, Function)
    • limitTolerance

      public static double limitTolerance
      Represents the largest difference between the left and right limit before the limit does not exist.
      See Also:
      limit(double, Function)
    • limitOffset

      public static double limitOffset
      Represents how far the x-value should be offset left and right to find the left and right limits.
      See Also:
      leftLimit(double, Function), rightLimit(double, Function)
    • SQUARE

      public static final int SQUARE
      Represents common known cross-sections types.
      See Also:
      crossSection(double, double, Function, Function, int), Constant Field Values
    • EQUILATERAL_TRIANGLE

      public static final int EQUILATERAL_TRIANGLE
      Represents common known cross-sections types.
      See Also:
      crossSection(double, double, Function, Function, int), Constant Field Values
    • ISOSCELES_TRIANGLE

      public static final int ISOSCELES_TRIANGLE
      Represents common known cross-sections types.
      See Also:
      crossSection(double, double, Function, Function, int), Constant Field Values
    • RIGHT_TRIANGLE

      public static final int RIGHT_TRIANGLE
      Represents common known cross-sections types.
      See Also:
      crossSection(double, double, Function, Function, int), Constant Field Values
    • SEMICIRCLE

      public static final int SEMICIRCLE
      Represents common known cross-sections types.
      See Also:
      crossSection(double, double, Function, Function, int), Constant Field Values
  • Constructor Details

    • Calculatte

      public Calculatte()
  • Method Details

    • round

      public double round(double x, int decimalPlaces)
      Rounds doubles according to the IEEE 754 standard of rounding half to even.

      Note: If decimalPlaces is set to -1, x will not be rounded.

      Parameters:
      x - The value to be rounded.
      decimalPlaces - The number of decimal places to round to.
      Returns:
      The rounded value.
    • integrate

      public double integrate(double a, double b, Function function)
      Integrates the function from a to b using Simpson's rule.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      function - The function to integrate.
      Returns:
      The area under the curve from a to b.
    • derivate

      public double derivate(double x, Function function)
      Finds the derivate of the function at point, x.
      Parameters:
      x - The point on the function to find the derivative.
      function - The function to find the derivative of.
      Returns:
      The derivative of the function at point, x or Double.Nan if the derivative DNE.
    • leftDerivative

      public double leftDerivative(double x, Function function)
      Finds the left derivate of the function at point, x.
      Parameters:
      x - The point on the function to find the derivative.
      function - The function to find the derivative of.
      Returns:
      The derivative of the function at point, x.
    • rightDerivative

      public double rightDerivative(double x, Function function)
      Finds the right derivate of the function at point, x.
      Parameters:
      x - The point on the function to find the derivative.
      function - The function to find the derivative of.
      Returns:
      The derivative of the function at point, x.
    • tangentLine

      public Function tangentLine(double x, Function function)
      Finds the tangent line of function at point, x.
      Parameters:
      x - The x-value at which to find the tangent line of.
      function - The function to find the tangent line of.
      Returns:
      The tangent line.
    • leftRiemannSum

      public double leftRiemannSum(double a, double b, Function function, int n)
      Finds the approximate area under the curve using the left Riemann sum rule with n rectangles.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      function - The function being used to calculate the left Riemann sum.
      n - The number of rectangles being used to estimate the area under the curve.
      Returns:
      The approximate area under the curve by the left Riemann sum rule.
    • rightRiemannSum

      public double rightRiemannSum(double a, double b, Function function, int n)
      Finds the approximate area under the curve using the right Riemann sum rule with n rectangles.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      function - The function being used to calculate the right Riemann sum.
      n - The number of rectangles being used to estimate the area under the curve.
      Returns:
      The approximate area under the curve by the right Riemann sum rule.
    • midpointRule

      public double midpointRule(double a, double b, Function function, int n)
      Finds the approximate area under the curve using the midpoint rule with n rectangles.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      function - The function being used to calculate the midpoint rule.
      n - The number of rectangles being used to estimate the area under the curve.
      Returns:
      The approximate area under the curve by the midpoint rule.
    • trapezoidalSum

      public double trapezoidalSum(double a, double b, Function function, int n)
      Finds the approximate area under the curve using the trapezoidal sum rule with n trapezoids.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      function - The function being used to calculate the trapezoidal sum.
      n - The number of trapezoids being used to estimate the area under the curve.
      Returns:
      The approximate area under the curve by the trapezoidal sum rule.
    • revolve

      public double revolve(double a, double b, double axis, Function functionTop, Function functionBottom)
      Finds the volume of revolution for the region bounded by functionTop, functionBottom, x = a, and x = b, about y = axis.

      Note: Vertical revolutions can also be made with this function. Input your data as if the data was rotated 90 degrees and to be rotated horizontally. There should be no mathematical difference between the two problems.

      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      axis - The y value of the axis of rotation, where 0 is about the x-axis.
      functionTop - The top function defining the bounded region.
      functionBottom - The bottom function defining the bounded region.
      Returns:
      The volume of revolution.
    • crossSection

      public double crossSection(double a, double b, Function functionTop, Function functionBottom, int type)
      Finds the volume of a known cross-section for any of the 5 common known cross-sections: square, equilateral triangle, isosceles triangle, right, triangle, and semicircle.

      Note: Constants have been defined in Calculatte for your ease of use when defining what type of cross-section you are solving for.

      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      functionTop - The top function defining the bounded region.
      functionBottom - The bottom function defining the bounded region.
      type - The type of cross-section.
      Returns:
      The volume of the known cross-section.
      See Also:
      SQUARE, EQUILATERAL_TRIANGLE, ISOSCELES_TRIANGLE, RIGHT_TRIANGLE, SEMICIRCLE
    • crossSection

      public double crossSection(double a, double b, Function integrand)
      Finds the volume of a known cross-section for a custom made cross-section formula.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      integrand - The integrand of the integral when taking the volume of a known cross-section.
      Returns:
      The volume of the known cross-section.
      See Also:
      crossSection(double, double, Function, Function, int)
    • limit

      public double limit(double x, Function function)
      Finds the limit of function at point x. Returns Double.NaN if the limit does not exist.
      Parameters:
      x - The x-value to find the limit at.
      function - The function to find the limit of.
      Returns:
      The value of the limit or Double.Nan if the limit DNE.
    • leftLimit

      public double leftLimit(double x, Function function)
      Finds the left limit of function at point x.
      Parameters:
      x - The x-value to find the limit at.
      function - The function to find the limit of.
      Returns:
      The value of the left limit.
    • rightLimit

      public double rightLimit(double x, Function function)
      Finds the right limit of function at point x.
      Parameters:
      x - The x-value to find the limit at.
      function - The function to find the limit of.
      Returns:
      The value of the right limit.
    • polarArea

      public double polarArea(double a, double b, Function r)
      Finds the area bounded by a polar function, r of theta, between two radian measures.
      Parameters:
      a - The lower limit of integration.
      b - The upper limit of integration.
      r - The polar function of theta bounding a specified area.
      Returns:
      The area of the bounded region.