This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function numerical_derivative(y, x) | |
""" | |
Compute the derivative of the function y(x) which has been sampled in discrete steps. The implementation here has | |
been adapted from Numpy's gradient function (centered finite differences). Boundaries have just forward differences. | |
It works only for 1D functions, but should be possible to easily extend to other things. | |
""" | |
#Create target vector | |
n = length(x) | |
derivs = Vector{Float64}(undef, n) |