Class Calculus


  • public class Calculus
    extends java.lang.Object
    A class containing many of the calculus operations
    Author:
    Bhagat
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double DEFAULT_DX
      Default infinitely small number
      static int DEFAULT_NUMBER_OF_ITERATIONS
      Default number of iterations for integrals
    • Constructor Summary

      Constructors 
      Constructor Description
      Calculus()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double averageValue​(Function<java.lang.Double,​java.lang.Double> function, double lowerBound, double upperBound)
      finds the average value of a function in an interval using the mean value theorem for integrals
      static double averageValue​(Function<java.lang.Double,​java.lang.Double> function, Interval interval)
      finds the average value of a function in an interval using the mean value theorem for integrals
      static Function<java.lang.Double,​java.lang.Double> derivative​(Function<java.lang.Double,​java.lang.Double> function)
      Takes the derivative of a function using a default dx
      static Function<java.lang.Double,​java.lang.Double> derivative​(Function<java.lang.Double,​java.lang.Double> function, double limitNumber)
      Takes the derivative of a double function using a non default dx
      static Function<java.lang.Float,​java.lang.Float> derivative​(Function<java.lang.Float,​java.lang.Float> function, float limitNumber)
      Takes the derivative of a float function using a non default dx
      static Function<java.lang.Double,​java.lang.Double> higherOrderDerivative​(Function<java.lang.Double,​java.lang.Double> function, int order)
      takes multiple derivatives on a double function
      static Function<java.lang.Double[],​java.lang.Double> integral​(Function<java.lang.Double,​java.lang.Double> function)
      takes the integral on a function
      static Function<java.lang.Double[],​java.lang.Double> integral​(Function<java.lang.Double,​java.lang.Double> function, int n)
      takes the integral on a function
      static Function<Interval,​java.lang.Double> integralWithInterval​(Function<java.lang.Double,​java.lang.Double> function)
      takes the integral on a function
      static Function<Interval,​java.lang.Double> integralWithInterval​(Function<java.lang.Double,​java.lang.Double> function, int n)
      takes the integral on a function
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_NUMBER_OF_ITERATIONS

        public static final int DEFAULT_NUMBER_OF_ITERATIONS
        Default number of iterations for integrals
        See Also:
        Constant Field Values
      • DEFAULT_DX

        public static final double DEFAULT_DX
        Default infinitely small number
        See Also:
        Constant Field Values
    • Constructor Detail

      • Calculus

        public Calculus()
    • Method Detail

      • derivative

        public static Function<java.lang.Double,​java.lang.Double> derivative​(Function<java.lang.Double,​java.lang.Double> function,
                                                                                   double limitNumber)
        Takes the derivative of a double function using a non default dx
        Parameters:
        function - the function
        limitNumber - the dx
        Returns:
        a function for the derivative of the input function
      • derivative

        public static Function<java.lang.Float,​java.lang.Float> derivative​(Function<java.lang.Float,​java.lang.Float> function,
                                                                                 float limitNumber)
        Takes the derivative of a float function using a non default dx
        Parameters:
        function - the function
        limitNumber - the dx
        Returns:
        a function for the derivative of the input function
      • derivative

        public static Function<java.lang.Double,​java.lang.Double> derivative​(Function<java.lang.Double,​java.lang.Double> function)
        Takes the derivative of a function using a default dx
        Parameters:
        function - the function
        Returns:
        a function for the derivative of the input function
      • higherOrderDerivative

        public static Function<java.lang.Double,​java.lang.Double> higherOrderDerivative​(Function<java.lang.Double,​java.lang.Double> function,
                                                                                              int order)
        takes multiple derivatives on a double function
        Parameters:
        function - the function
        order - the order of the derivative you want to take
        Returns:
        the function after multiple derivatives
      • integral

        public static Function<java.lang.Double[],​java.lang.Double> integral​(Function<java.lang.Double,​java.lang.Double> function,
                                                                                   int n)
        takes the integral on a function
        Parameters:
        function - the function to take the integral of
        n - the number of iterations
        Returns:
        a function for the definite integral
      • integralWithInterval

        public static Function<Interval,​java.lang.Double> integralWithInterval​(Function<java.lang.Double,​java.lang.Double> function,
                                                                                     int n)
        takes the integral on a function
        Parameters:
        function - the function to take the integral of
        n - the number of iterations
        Returns:
        a function for the definite integral
      • averageValue

        public static double averageValue​(Function<java.lang.Double,​java.lang.Double> function,
                                          Interval interval)
        finds the average value of a function in an interval using the mean value theorem for integrals
        Parameters:
        function - the function
        interval - the interval
        Returns:
        the mean value
      • averageValue

        public static double averageValue​(Function<java.lang.Double,​java.lang.Double> function,
                                          double lowerBound,
                                          double upperBound)
        finds the average value of a function in an interval using the mean value theorem for integrals
        Parameters:
        function - the function
        lowerBound - the lower bound of the interval
        upperBound - the upper bound of the interval
        Returns:
        the mean value
      • integral

        public static Function<java.lang.Double[],​java.lang.Double> integral​(Function<java.lang.Double,​java.lang.Double> function)
        takes the integral on a function
        Parameters:
        function - the function to integrate
        Returns:
        a function for the definite integral
      • integralWithInterval

        public static Function<Interval,​java.lang.Double> integralWithInterval​(Function<java.lang.Double,​java.lang.Double> function)
        takes the integral on a function
        Parameters:
        function - the function to integrate
        Returns:
        a function for the definite integral