С将Hermite多项式的系数倾斜到一个函数

发布于 2025-01-30 04:57:17 字数 953 浏览 5 评论 0原文

我想从MATLAB HERMITE函数的输出中制作功能(例如,如果我们从HERMITE函数输出[8 0 -12 0]它将是8x^3-12X多项式),然后使用 simpson的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

Simpson函数的代码,使用Simpson 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

谢谢您的任何建议!

I want to make a function from the output of Matlab Hermite function (for example, if we had an output from Hermite function [8 0 -12 0] it would be 8x^3 - 12x polynomial) and then integrate this function using the Simpson's 3/8 Rule.

I have already created a function in Matlab that integrate any function using this rule and also I have created function that returns coefficients of Hermite's polynomial (with the recursion relation) in the vector form.

My questions:

  1. If it's possible, in Hermite function I want from this output [8 0 -12 0] make this output 8x^3 - 12x. This output I will able to integrate. How can I do this?
  2. Can I combine these two functions and integrate Hermite's polynomial without convention the output of the first function?

Code of Hermite polynomial function, where n is the order of the polynomial:

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

Code of Simpson function, that integrate function using the Simpson 3/8 Rule. a is a lower limit of integral, b is a upper limit of integral:


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

Thank you for any advice!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呢古 2025-02-06 04:57:17

要在其系数下创建一个多项式函数,您可以使用代码> (另请参见 em> ):

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函数将返回代表代表该功能的功能(handle) Hermite多项式。

To create a polynomial function given its coefficients, you can use polyval (see also anonynmous functions):

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

Now f is a function that you can integrate numerically.

If you want to include this directly as part of your Hermite function, just add something like this at the end:

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

Then the Hermite function will return a function (handle) representing the Hermite polynomial.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文