I try to calculate the 1st derivatives of Hermite function using `gsl_sf_hermite_func_der_e(1, n ,x, result)`, following the documentation

https://www.gnu.org/software/gsl/doc/html/specfunc.html#derivatives-of-hermite-functions

The results seem incorrect for n = 0 and n=1.

For n=0,  `result.val` always gives 0 for any x. However, psi_0(x) is basically a Gaussian function and the 1st derivative of psi_0(x)  is proportional to  -x*exp(-x^2/2), which does not vanish for a nonzero x.

Similarly, for n=1 `gsl_sf_hermite_func_der_e` also gives incorrect result.

I dig a little bit in the source code  `hermite.c` and I find that from line 1189 to 1222,  in the branch of 1st derivative (m=1)  case, the code uses the relation  psi'_n(x) = sqrt(2 n) psi_{n-1} - x psi_n, but the recursion (line 1198 to line 1214) starts with i=2 and ends with i<=n, which has exclude n=0 and n=1 cases and the initial values of some intermediate variables make psi'_0(x) to be zero.

For n >=2, the results are as expected.


I am wondering is this behavior intended?  My GSL version is 2.7.


Bests,

Xiaonu Xiong


Reply via email to