C++用递归方法求n阶联缔勒让德多项式式

扫描二维码,关注牛客网
下载牛客APP,随时随地刷题
浙ICP备号-2
扫一扫,把题目装进口袋c++用递归法求n阶勒让德多项式的值!式子是这个 1 (n=0) Pn(x)= x (n=1) ((2n-1)·x - Pn-1 (x)-(n-1)·Pn- 2(x))/n (n>=1)我编的程序如下#include double pn(int n,int x){ if(n==0)z=1;if(n==1)z=x;if(n>1)z=((2*n-1)*x-pn(n-1,x)-(n-1)*pn(n-2,x))/n;}int main(){int a,b;couta>>b;cout
// 很简单,应该是答案印错了// 不过这样才是正确的递归方式double legendre(int n, double x) { if (n == 0) return 1; else if (n == 1) else return ( (2*n-1)*x - legendre(n-1,x) - (n-1)*legendre(n-2,x) ) / }
为您推荐:
其他类似问题
扫描下载二维码

我要回帖

更多关于 勒让德多项式 的文章

 

随机推荐