Class FiniteDifference

    • Constructor Detail

      • FiniteDifference

        public FiniteDifference​(UnivariateRealFunction f,
                                int order,
                                FiniteDifference.Type type)
        Construct an approximate derivative function for f using finite difference.
        Parameters:
        f - a univariate function
        order - the order of the derivative
        type - the type of finite difference to use, c.f., FiniteDifference.Type
    • Method Detail

      • evaluate

        public double evaluate​(double x)
        Description copied from interface: UnivariateRealFunction
        Evaluate y = f(x).
        Parameters:
        x - x
        Returns:
        f(x)
      • evaluate

        public double evaluate​(double x,
                               double h)
        Evaluate numerically the derivative of f at point x, f'(x), with step size h. It could be challenging to automatically determine the step size h, esp. when |x| is near 0. It may, for example, require an analysis that involves f' and f''. The user may want to experiment with different hs by calling this function.
        Parameters:
        x - the point to evaluate the derivative of f at
        h - step size
        Returns:
        f'(x), the numerical derivative of f at point x with step size h
      • df

        public double df​(double x,
                         double h)
        Compute the finite difference for f at x with an increment h for the n-th order using either forward, backward, or central difference.
        Parameters:
        x - the point to evaluate the function at
        h - the increment
        Returns:
        \(\Delta^n_hf(x)\)
        See Also:
        Wikipedia: Higher-order differences