Vector calculation of HermiteH Polynomials
Afficher commentaires plus anciens
The function im trying to code is hermiteH and it is as follows:

I want to create a vector of n hermite polynomials, and then each one to go through
, some sort of matrix operation comes to mind but the implementation eludes me.

My goal is to get something like
be run through
.
In the example ill get
with
.
My current Code:
Hk = @(k,x) hermiteH(k,x/sqrt(2))*2.^(-k/2);
k = 2;
hPoly = zeros(1,k+1);
for i=1:k
hPoly = hPoly + Hk(i,[0 1 2]);
end
hPoly
The code is Not right.
- The MATLAB hermiteH is the "physicist's Hermite polynomials" (i.e.
) and not the "probabilist's Hermite polynomials" (i.e.
) I'm looking for but I "fixed" it with the extra "
" term, but I'm not sure. - The result is wrong and I cant get it right.
- The end goal is to implement the Wolfram syntax into a functional MATLAB code with k and x variables. note: to make multiple polynomials in one vector with the hermiteH command it requires k to be a vector (i.e. 1:7) and x to be symbolic so basically k is a vector and x is a vector and make the implementation versetile.
- The problem I think is the first term in the result adds the first Hermite k times, the second Hermite k-1 times and so on...
Any advice on the matter is much obliged.
4 commentaires
I have derived this from the code I wrote for "physicist's Hermite polynomials" and transformed it according to the rescaling equations from Wikipedia.
The code gives the coefficients of polynomials in the form of a vector. However, this code is susceptible to rounding errors as it includes multiplication with irrational values.
I'll update the code with the actual algorithm for probabilist's Hermite polynomial when I'll get the time. Hope this helps.
n=5;
%physicist's hermite polynomial
q=1;
for i=1:n
y=conv([-2 0],q);
der=polyder(q);
q=y+[zeros(1,numel(y)-numel(der)) der];
end
y=sqrt(2);
q=q*(-1)^n
%probabilit's hermite polynomial
p=q.*y^(-n).*y.^-(n:-1:0)
Alex Rudyak
le 17 Jan 2023
conv is the classic MATLAB trick for multiplication of polynomials or many other things. You can use it to build polynomials, etc. I even used it in my VPI toolbox to perform multiplication of variable precision numbers. For example, suppose you want to multiply a pair of polynomials? I'll do it using syms first.
Suppose I want to multiply (x+1) by (x^2 - 3*x - 2)? Firt, in symbolic form so we can compare the results.
syms x
expand((x+1)*(x^2 - 3*x - 2))
But now recognize that these polynomials can be represented as a list of coefficients in standard MATLAB form.
conv([1,1],[1 -3 -2])
Do you see the multiplication worked perfectly? As a result, we now have a list of coefficients of the product polynomial. Try it with other products of polynomials, and it always works, at least as long as there are no problems with the precision of the coefficients in double precision arithmetic.
Why does it work? Think about what conv does. Expand it out, and you will see that convolution does exactly what you want with the product of those polynomials. (Conv is a tremendously valuable tool, useful in many areas of mathematics. I cannot begin to count the number of ways I have used it over the years.)
Alex Rudyak
le 18 Jan 2023
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
