bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] Contribution: Hermite polynomials, functions etc.


From: Konrad
Subject: [Bug-gsl] Contribution: Hermite polynomials, functions etc.
Date: Sun, 13 Oct 2013 18:10:44 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear GSL-Team,

a while back I asked how to submit some of my work and was told to
send it to this address. So here it goes!
There's a piece of code I'd like to contribute to your great library.
It consists of a few functions to compute Hermite polynomials, Hermite
functions and their respective derivatives, please see the attachment
gsl_hermite.c. I have tried to name them in such a way that they can
directly be used in the GSL, but since I'm not sure about any policies
please feel free to make any changes you deem neccessary.
Here's an overview:

- - gsl_sf_hermite_prob(const int n, const double x): Evaluates the
probabilists' Hermite polynomial of order n at position x.
- - gsl_sf_hermite_prob_der(int m, int n, double x): Evaluates the m-th
derivative of the probabilists' Hermite polynomial of order n at
position x.
- - gsl_sf_hermite_phys(const int n, const double x): Evaluates the
physicists' Hermite polynomial of order n at position x.
- - gsl_sf_hermite_phys_der(int m, int n, double x): Evaluates the m-th
derivative of the physicists' Hermite polynomial of order n at position x.
- - gsl_sf_hermite_func(const int n, const double x): Evaluates the
Hermite function of order n at position x.
- - gsl_sf_hermite_prob_series(const int n, const double x, const double
* a): Evaluates the series sum_{j=0}^n a_j*He_j(x) with He_j being the
j-th probabilists' Hermite polynomial.
- - gsl_sf_hermite_prob_array(const int nmax, const double x, double *
result_array): Evaluates all probabilists' Hermite polynomials up to
order nmax at position x. The results are stored in result_array.
- - gsl_sf_hermite_prob_array_der(const int m, const int nmax, const
double x, double * result_array): Evaluates the m-th derivative of all
probabilists' Hermite polynomials up to order nmax at position x. The
results are stored in result_array.
- - gsl_sf_hermite_prob_der_array(const int mmax, const int n, const
double x, double * result_array): Evaluates all derivatives (starting
from 0) up to the mmax-th derivative of the probabilists' Hermite
polynomial of order n at position x. The results are stored in
result_array.
- - gsl_sf_hermite_prob_series(const int n, const double x, const double
* a): Evaluates the series sum_{j=0}^n a_j*He_j(x) with He_j being the
j-th probabilists' Hermite polynomial.
- - gsl_sf_hermite_phys_array(const int nmax, const double x, double *
result_array): Evaluates all physicists' Hermite polynomials up to
order nmax at position x. The results are stored in result_array.
- - gsl_sf_hermite_phys_array_der(const int m, const int nmax, const
double x, double * result_array): Evaluates the m-th derivative of all
physicists' Hermite polynomials up to order nmax at position x. The
results are stored in result_array.
- - gsl_sf_hermite_phys_der_array(const int mmax, const int n, const
double x, double * result_array): Evaluates all derivatives (starting
from 0) up to the mmax-th derivative of the physicists' Hermite
polynomial of order n at position x. The results are stored in
result_array.
- - gsl_sf_hermite_phys_series(const int n, const double x, const double
* a): Evaluates the series sum_{j=0}^n a_j*H_j(x) with H_j being the
j-th physicists' Hermite polynomial.
- - gsl_sf_hermite_func_array(const int nmax, const double x, double *
result_array): Evaluates all Hermite functions up to order nmax at
position x. The results are stored in result_array.
- - gsl_sf_hermite_func_series(const int n, const double x, const double
* a): Evaluates the series sum_{j=0}^n a_j*Psi_j(x) with Psi_j being
the j-th Hermite function.
- - gsl_sf_hermite_func_der(const int m, const int n, const double x):
Evaluates the m-th derivative of the Hermite function of order n at
position x.

As you can see, the routines for the polynomials exist in the
probabilists' and the physicists' versions. If a default has to be
chosen, I'd suggest the probabilists' routines due to their smaller
susceptibility to overflow.
The naming of the routines may be an issue especially with
gsl_sf_hermite_prob_array_der vs. gsl_sf_hermite_prob_der_array (and
their physicists' equivalents), I'm not sure this is a very clear
choice, but I kept it for lack of a better idea.
Please find a very simple test of the routines in the second
attachment (gsl_hermite_test.c). A more thorough check would make sense.
Also included in the code is a small ToDo-list for additional
functionality. Unfortunately I probably won't be able to put a lot of
work into this at the moment. (I've had this code laying around for
quite a while already and only now got around to preparing it for the
GSL...)

There is only one issue that requires your attention: as I don't know
if there are any rules as to when an asymptotic approximation is to be
used instead of the (slower) standard calculation, I have set the
limit to the order 10000 (orders above that often result in overflow),
please adjust this value.

If there's anything that needs to be done before the functions can be
included in the next release (like writing documentation), please let
me know how I can help. In that case it would be good to know what the
deadline for the upcoming release is.

On a completely unrelated topic: the last digit in the first zero of
the Airy function Ai is wrong in the GSL-function: it reads
- -2.338107410459767039 instead of
- -2.338107410459767038, which is correct.

Last but not least: thanks you all for your time and effort, you've
helped many people a great deal!

Cheers,
Konrad
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSWsYEAAoJENt9LIzl6S/tn8IP/AyWEhaDaLUhp8EIXvqO0v7a
eKjy2veS1QTBnBwQTyiYxDyQex3LRywtCZWvEYp9vBZEZveHjvdRB/AW9Yi+DbmT
lspCTDIIP/sAhrFhU3XCYf8sH+uaz75E0pkljlNjTZ0lkAlitKYqZoimoYA4LHVD
20giPQduAcaXVoUJc34m9oxHvE4UGrNz5xcx1uaFc5x3lDZTa+cXLaFqq4Ifyq6X
Rc/OCXOL2C2KFmCDRN9rOZMZ51RBK1IIrxKYd+geI69JE22MlPVPRslW3SnrMsEI
zqjKwiE6BSALtLkNzFnEhHcH2+wkDhiIjnkET9j+u6Bw56sbihV82qd+iWqXMInn
EcafAZeg7NnluiObAGWhZa8h6crBHIU1uFTCBHfEOfa4+2TYqEybTXAywhZjxppI
9oplhA3egxAsR2nO649YJVxexqPBV/KtVc7+N+fS7U8eZm5OBUBU+/V69uz4tMMf
TcSAnlRQzKg4oy1lxPHmtLk20+qjVL7g309lo4Owsyvjhah8AJe4GzATlVFJhZ3s
5vQXRchI4v/XT6QfmHC/f1ONfDFTToG9zHE72yjNlePEpjd1cZa9+skWwJi/aYME
sCQjgAxcyowM8ExBngzFGd1t3tFAnpNAv4BC9SWGhQzPi6EQrTgK0bDp500WmAxi
oEYJ4uMGes6FCCe62L5L
=WE14
-----END PGP SIGNATURE-----

Attachment: gsl_hermite.c
Description: Text Data

Attachment: gsl_hermite_test.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]