Compute the first derivative using a 2-point central difference [-h,h].
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
procedure(func) | :: | f | ||||
complex(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h | |||
real(kind=wp), | intent(out) | :: | dfdx |
subroutine central_diff(f,x,h,dfdx) implicit none procedure(func) :: f complex(wp),intent(in) :: x real(wp),intent(in) :: h real(wp),intent(out) :: dfdx dfdx = (f(x+h) - f(x-h)) / (2.0_wp*h) end subroutine central_diff