埃尔米特多项式

编写Hermite多项式的递归函数或非递归函数,并输出第n项Hermite(x)式的值。
埃尔米特多项式埃尔米特多项式是一组正交的多项式。
前 10 个 埃尔米特多项式如下:
在这里插入图片描述
规律:当x>1时,Hermite多项式定义为:
H0(x)=1H1(x)=2xHn(x)=2xHn-1(x)-2(n-1)Hn-2(x)

#include <iostream>
#include <iomanip>
using namespace std;
double hermite(int n, double x);
int main()  
{  
      int a;
      double b;
      double M;
      cin>>a>>b;
      M=hermite(a,b);
      cout<<M;
    return 0;  
}
double hermite(int n, double x)  
{  
    if(n<=0)  
    return 1;
    else if(n==1)  
    return 2*x; 
    else 
    return     2*x*hermite(n-1,x)-2*(n-1)*hermite(n-2,x);
}  
发布了102 篇原创文章 · 获赞 93 · 访问量 4954

猜你喜欢

转载自blog.csdn.net/huangziguang/article/details/104797676
今日推荐