diff --git a/matlab/compute/HermitePhys.m b/matlab/compute/HermitePhys.m new file mode 100644 index 0000000000000000000000000000000000000000..e5c0bc5829c3dc8cf1977b5c12e6f8b3be122d26 --- /dev/null +++ b/matlab/compute/HermitePhys.m @@ -0,0 +1,40 @@ + +% 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 diff --git a/matlab/compute/HermitePhys_norm.m b/matlab/compute/HermitePhys_norm.m new file mode 100644 index 0000000000000000000000000000000000000000..eca67bb26573a7e4c889462a0a6139b612deb89b --- /dev/null +++ b/matlab/compute/HermitePhys_norm.m @@ -0,0 +1,42 @@ +% 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;