Skip to content
Snippets Groups Projects
Commit dc225672 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann :seedling:
Browse files

add hermite polynomials computation and normalized

parent 0dcd6790
Branches
Tags
No related merge requests found
% HermitePoly.m by David Terr, Raytheon, 5-10-04
% Given nonnegative integer n, compute the
% Hermite polynomial H_n. Return the result as a vector whose mth
% element is the coefficient of x^(n+1-m).
% polyval(HermitePoly(n),x) evaluates H_n(x).
function hk = HermitePoly(n)
% Evaluate the normalized Hermite polynomial.
if n==0
hk = 1;
elseif n==1
hk = [2 0];
else
hkm2 = zeros(1,n+1);
hkm2(n+1) = 1;
hkm1 = zeros(1,n+1);
hkm1(n) = 2;
for k=2:n
hk = zeros(1,n+1);
for e=n-k+1:2:n
hk(e) = 2*(hkm1(e+1) - (k-1)*hkm2(e));
end
hk(n+1) = -2*(k-1)*hkm2(n+1);
if k<n
hkm2 = hkm1;
hkm1 = hk;
end
end
end
\ No newline at end of file
% Normalized version of
% HermitePoly.m by David Terr, Raytheon, 5-10-04
% Given nonnegative integer n, compute the
% Hermite polynomial H_n. Return the result as a vector whose mth
% element is the coefficient of x^(n+1-m).
% polyval(HermitePoly(n),x) evaluates H_n(x).
function hk = Hp(n)
% Evaluate the normalized Hermite polynomial.
if n==0
hk = 1;
elseif n==1
hk = [2 0];
else
hkm2 = zeros(1,n+1);
hkm2(n+1) = 1;
hkm1 = zeros(1,n+1);
hkm1(n) = 2;
for k=2:n
hk = zeros(1,n+1);
for e=n-k+1:2:n
hk(e) = 2*(hkm1(e+1) - (k-1)*hkm2(e));
end
hk(n+1) = -2*(k-1)*hkm2(n+1);
if k<n
hkm2 = hkm1;
hkm1 = hk;
end
end
end
% Normalization
% hk = 1/sqrt(2^n*factorial(n))/sqrt(sqrt(pi))*hk;
hk = 1/sqrt(2^n*factorial(n))/sqrt(sqrt(pi))*hk;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment