The coefficients of a Hermite polynomial

9 ビュー (過去 30 日間)
Magdy Hanna
Magdy Hanna 2025 年 6 月 13 日
編集済み: David Goodmanson 2025 年 6 月 14 日
After the coomand:
H = hermiteH(n, sym('t')) ;
which generates a Hermite polynomial of degree n.
I need to get a vector of its coefficients.

採用された回答

Matt J
Matt J 2025 年 6 月 13 日
syms t
n = 4; % Degree of the Hermite polynomial
H = hermiteH(n, t); % Generate Hermite polynomial of degree n
coeffs_vec = sym2poly(H); % Get vector of coefficients
disp(coeffs_vec);
16 0 -48 0 12

その他の回答 (2 件)

Paul
Paul 2025 年 6 月 13 日
n = 4;
H = hermiteH(n, sym('t'))
H = 
[c,terms] = coeffs(H,sym('t'))
c = 
terms = 
or
[c,terms] = coeffs(H,sym('t'),'all')
c = 
terms = 
Typically one would declare t as workspace variable
syms t
H = hermiteH(n,t);
[c,terms] = coeffs(H,t,'all')
c = 
terms = 

David Goodmanson
David Goodmanson 2025 年 6 月 14 日
編集済み: David Goodmanson 2025 年 6 月 14 日
Hi Magdy,
For a change of pace, here is a function that calculates the coefficents of Hn by recursion. I didn't want to get into variable precision arithmetic but with double precision it's good to somewhere around n = 25. Usual Matlab notation so e.g.
hermite(6)
ans = 64 0 -480 0 720 0 -120
means 64x^6 - 480x^4 + 720x^2 - 120
function H = hermite(n)
% hermite polynomial coefficients
% usual Matlab convention with highest power first, constant term last
% H_n+1(x) = 2xH_n(x) - H_n(x)'
%
if n==0
H = 1;
else
A = hermite(n-1);
H = 2*[A 0] - [0 0 (n-1:-1:1).*A(1:end-1)];
end

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by