勒讓德多項(xiàng)(xiàng)式遞推關(guān)(guān)系證明
濯晨15281695635咨詢: 用遞歸的方法編寫函數(shù)求n階勒讓德多項(xiàng)式的值 -
盧氏縣面齒距回復(fù):
______ double pN(int n,double x) { double c; if(n==0) c=1; else if(n==1) c=x; else c=((2*n-1)*x*pN(n-1,x)-(n-1)*pN(n-2,x))/n; return c; }
濯晨15281695635咨詢: C語言:用遞歸方法求n階勒讓德多項(xiàng)式的值 -
盧氏縣面齒距回復(fù):
______ if (n=0) return(1); ////判讀相等 使用 == else if (n=1) return(x); ///同上 一個(gè)= 表示賦值,不是判斷
濯晨15281695635咨詢: 編一個(gè)函數(shù)用遞歸方法計(jì)算x的n階勒讓德多項(xiàng)式的值,請幫忙看看我的哪兒錯(cuò)了. -
盧氏縣面齒距回復(fù):
______ else if(n>1) a=((2n-1)*x*p(n-1,x)-(n-1)*p(n-2,x))/n;//少了個(gè)*,改為else if(n>1) a=((2*n-1)*x*p(n-1,x)-(n-1)*p(n-2,x))/n
濯晨15281695635咨詢: 用遞歸的方法編寫函數(shù)求n 階勒讓德多項(xiàng)式的值,在主程序中實(shí)現(xiàn)輸入輸出,公式為
盧氏縣面齒距回復(fù):
______ Pn(X)=1 (n=0) Pn(X)=X (n=1) Pn(X)=((2n-1)XPn-1(X)-(n-1)Pn-2(X))/n (n>1)
濯晨15281695635咨詢: JAVA 編程序 用遞歸方法求n階勒讓德多項(xiàng)式的值,(x、n均為整數(shù)) -
盧氏縣面齒距回復(fù):
______ public int fun(int x,int n){ if(n==0)return 1; else if(n==1)return x; else{ return ((2*n-1)*x-fun(x,n-1)-(n-1)*fun(x,n-2))/n; }
濯晨15281695635咨詢: C語言用遞歸方法求n階勒讓德多項(xiàng)式 -
盧氏縣面齒距回復(fù):
______ y=((2*n-1)*x-lerang(n-1,x)-(n-1)*lerang(n-2,x))/n; 少寫了參數(shù)
濯晨15281695635咨詢: 編程,求n階勒讓德多項(xiàng)式(遞歸) -
盧氏縣面齒距回復(fù):
______ #include float myfunction(int n,int x){ if (0 == n) { return 1; } else if (1 == n) { r...
濯晨15281695635咨詢: C語言編程n階勒讓德多項(xiàng)式的值
盧氏縣面齒距回復(fù):
______ double legendre(int n, double x) { if (n == 0) return 1; else if (n == 1) return x; else return ( (2*n-1)*x - legendre(n-1,x) - (n-1)*legendre(n-2,x) ) / n; }
濯晨15281695635咨詢: (3)編寫程序,用遞歸法求n階勒讓德多項(xiàng)式寫,如圖 -
盧氏縣面齒距回復(fù):
______ #include float myfunction(int,int); int main(int argc, char *argv[]) { int n,x; float result; printf("please inputa n,x:"); scanf("%d,%d",&n,&x); result = myfunction(n,x); printf("the result is : %f",result); system("pause"); return 0; } float myfunction(int ...
濯晨15281695635咨詢: C++題“已知計(jì)算x的n階勒讓德多項(xiàng)式的公式如下:” -
盧氏縣面齒距回復(fù):
______ #include<stdio.h> void main() { int x,n; float p(int,int); printf("\ninput n& x:"); scanf("%d,%d",&n,&x); printf("n=%d,x=%d\n",n,x); printf("P%d(%d)=%6.2f\n",n,x,p(n,x)); } float p(int n,int x) { if(n==0) return 1; else if(n==1) return x; else return((2*n-1)*x*p((n-1),x)-(n-1)*p((n-2),x))/n; }