I have a two vectors:
- Coordinates along an axis,
x
; - An evaluation of a function on those coordinates,
f(x)
.
and I want to compute an estimate of the first derivative of f
at these coordinates.
The function is a descriptor of a wavefunction and x is the dihedral angle.
Because the result vector must have the same length as the two existing vectors, I cannot use a manual implementation based on Newton's difference quotient.
In Python, I can obtain such an estimate using the scipy
library:
spline = UnivariateSpline(X, Y, k=4, s=0)
sd = spline.derivative(n=1)
Perhaps I can do something similar in C++?
x
vector, but you have to consider some "boundary conditions". The solution you wrote in python consists of creating a fit of the original function and then deriving the latter, you are not computing the derivatives of the original function (although you may achieve a good rate of approximation depending onf
). - Eddymage