繁体   English   中英

将 Hermite 多项式的系数转换为函数

[英]Сonvert the coefficients of the Hermite polynomial into a function

我想从 Matlab Hermite 函数的输出中创建一个函数(例如,如果我们有 Hermite 函数[8 0 -12 0]的输出,它将是8x^3 - 12x多项式),然后使用Simpson's集成该函数3/8 规则

我已经在 Matlab 中创建了一个函数,该函数使用此规则集成任何函数,并且我还创建了以向量形式返回 Hermite 多项式(具有递归关系)的系数的函数。

我的问题:

  1. 如果可能的话,在 Hermite 函数中,我想从此输出[8 0 -12 0]将此输出8x^3 - 12x 这个输出我将能够整合。 我怎样才能做到这一点?
  2. 我可以结合这两个函数并整合 Hermite 的多项式而不约定第一个函数的输出吗?

Hermite 多项式函数的代码,其中 n 是多项式的阶数:

function h = hermite_rec(n)

if( 0==n ), h = 1;
elseif( 1==n ), h = [2 0];
else
   h1 = zeros(1,n+1);
   h1(1:n) = 2*hermite_rec(n-1);

   h2 = zeros(1,n+1);
   h2(3:end) = 2*(n-1)*hermite_rec(n-2);

   h = h1 - h2;

end

辛普森函数代码,使用辛普森 3/8 规则集成函数。 a 为积分下限,b 为积分上限:


n = 3;
h = (b-a)/(3*n);  %3h = (b-a)/n

IS2=0;
for i=1:n
    IS2 = IS2+(f(a+(3*i-3)*h) + 3*f(a+(3*i-2)*h) + 3*f(a+(3*i-1)*h) + f(a+(3*i)*h))*3*h/8;
end

end

感谢您的任何建议!

要在给定系数的情况下创建多项式函数,可以使用polyval (另请参见匿名函数):

p = [1 2]; % example. This represents the polynomial x+2
f = @(x) polyval(p, x); % anonymous function of x, assigned to function handle f

现在f是一个可以数值积分的函数。

如果您想直接将其作为Hermite函数的一部分包含在内,只需在末尾添加如下内容:

h = @(x) polyval(p, x);

然后Hermite函数将返回一个表示 Hermite 多项式的函数(句柄)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM