/*
 Date: 07/03/19 15:40
 Description: 用递归法求n阶勒让德多项式的值
           { 1     n=0
      Pn(x)=  { x     n=1
           { ((2n-1).x-Pn-1(x)-(n-1).Pn-2(x)/n   n>=1
*/
#include<stdio.h>
float Legendre(int x,int n);
int main(void)
{
   int x,n;
   float value;
   printf("Enter the order of the polynomials:\n");
     scanf("%d %d",&n,&x);
   printf("n=%d,x=%d\n\n",n,x);
     value=Legendre(x,n);
   printf("P%d(%d)=%6.3f\n",n,x,value);
   return 0;
 }
float Legendre(int x,int n)
 {
   float value;
    if(n==0)
       value=1;
    else if(n==1)
       value=x;
    else
       value=((2*n-1)*x-Legendre(x,n-1)-(n-1)*Legendre(x,n-2))/n;
    return value;
 }

  

 
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-08-28
相关资源
相似解决方案