С将Hermite多项式的系数倾斜到一个函数
我想从MATLAB HERMITE函数的输出中制作功能(例如,如果我们从HERMITE函数输出[8 0 -12 0]
它将是8x^3-12X
多项式),然后使用 simpson的3/8规则集成此功能。
我已经在MATLAB中创建了一个使用此规则集成任何函数的函数,并且也创建了函数,以返回向量形式的Hermite多项式(带有递归关系)系数的功能。
我的问题:
- 如果可能的话,在Hermite函数中,我希望从此输出
[8 0 -12 0]
使此输出8X^3-12X
。我将能够集成此输出。我该怎么做? - 我可以将这两个函数结合起来并整合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:
- If it's possible, in Hermite function I want from this output
[8 0 -12 0]
make this output8x^3 - 12x
. This output I will able to integrate. How can I do this? - 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在其系数下创建一个多项式函数,您可以使用代码> (另请参见 em> ):
现在
f
是您可以数值集成的函数。如果要直接将其作为
hermite
函数的一部分,只需在最后添加类似的内容:然后,
hermite
函数将返回代表代表该功能的功能(handle) Hermite多项式。To create a polynomial function given its coefficients, you can use
polyval
(see also anonynmous functions):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:Then the
Hermite
function will return a function (handle) representing the Hermite polynomial.