递归算法计算Legendre多项式
生活随笔
收集整理的這篇文章主要介紹了
递归算法计算Legendre多项式
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
定義Legendre多項式:
? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
C++實現(xiàn):
#include<iostream> using namespace std; float Legendre(float x,int n) {if(n==0)return 1;if(n==1)return x;if(n>1)return ((2*n-1)*x*Legendre(x,n-1)-(n-1)*Legendre(x,n-2))/n;}?int main(){float x,y;int n;cin>>x>>n;y=Legendre(x,n);cout<<y;}測試結(jié)果:
總結(jié)
以上是生活随笔為你收集整理的递归算法计算Legendre多项式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UAP安装使用FindBugs
- 下一篇: 人工智能数据标注平台推荐