I was wandering - what kind of normalization does Matlab use in hermiteH
, its implementation of the Hermite polynomials?
It is certainly not the case that they use either $\| H_n \|_{L^2 (e^{-x^2})}=1$, and they don't use $H_n(1)=1$ either.
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It only takes a minute to sign up.
Sign up to join this communityI was wandering - what kind of normalization does Matlab use in hermiteH
, its implementation of the Hermite polynomials?
It is certainly not the case that they use either $\| H_n \|_{L^2 (e^{-x^2})}=1$, and they don't use $H_n(1)=1$ either.
Several packages (MATLAB, Mathematica, SciPy, mpmath) have implemented the physicist Hermite polynomials, they are defined by
$$H_n(x)=(-1)^n e^{x^2}\frac{\mathrm d^n}{\mathrm dx^n}e^{-x^2}=\left (2x-\frac{\mathrm d}{\mathrm dx} \right )^n \cdot 1$$
They are not normalized, the norm should be
$$||H_n(x)||_{L^2(e^{-x^2})} = 2^n \sqrt{\pi} n!\, .$$
These polynomials are orthogonal with respect to the weight $e^{-x^2}$, i.e.
$$\int_{-\infty}^\infty H_m(x) H_n(x)\, e^{-x^2}\, \mathrm{d}x = 2^n \sqrt{ \pi} n! \delta_{nm}\, .$$
If you want to check this orthogonality/normalization numerically you need to be careful. On one hand, you have an infinite interval. As you say, you can make the integration region "big-enough", but you have a caveat: the maximum value of the polynomials grow really fast, and you will need to increase the size of the region, really fast, as well. See, for example, the result of using the trapezoidal rule for the orthogonality between $H_0$ and $\{H_2, H_4, H_6, H_8\}$ using the interval [-3, 3] as you propose.
We can increase the integration interval to, say, [-10, 10] to obtain
where we see that all the considered polynomials are "orthogonal". Nevertheless, you have another complication when you increase the order of the polynomials: the number of changes of sign increases. For that you need to consider a special type of quadrature or use something like Chebfun.
trapz
on a bounded interval w.r.t. the normal measure doesn't return $0$. @nicoguaro $\endgroup$trapz
won't do the trick. $\endgroup$