get_numerical_derivative Subroutine

public subroutine get_numerical_derivative(x, y, dy, dxtol)

Calculates the numerical derivative of a given array. A sixth-order accurate central difference stencil is used to calculate the derivative. Near the edges a sixth-order accurate forward and backward difference stencil is used for the left and right boundary, respectively. It is assumed that the x values are all equally spaced. If this is not the case, a polynomial interpolation on a uniform grid can be done and that one can be differentiated instead. The stencils are as follows:

  • 6th order central differences:
  • 6th order forward differences:
  • 6th order backward differences:

Arguments

TypeIntentOptionalAttributesName
real(kind=dp), intent(in) :: x(:)

x-values against which to differentiate

real(kind=dp), intent(in) :: y(:)

array of y-values, assuming relation

real(kind=dp), intent(out) :: dy(size(y))

derivative of with respect to , same size as input arrays

real(kind=dp), intent(in), optional :: dxtol

optional tolerance for equally spaced arrays


Contents

None