[問題] 新手Abel transform 積分問題 (附CODE)

看板C_and_CPP (C/C++)作者 (羊羽)時間13年前 (2013/05/15 21:59), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
如題 在下為C語言新手 對C語言 尚不是太了解 麻煩請各位指點 我的CODE為: http://ideone.com/0XTxhW #include "stdio.h" #include "math.h" double func(double x) // 欲微分函數 { return sin (x) ;} double FordDiff(double x, double h, double (*fx)(double)) { // 前差微分 return ( fx(x+h) - fx(x) ) / h; } double f (double x, double r) { return ( 1 / sqrt(x*x-r*r)); (我想將前面的前差微分結果放置此積分項的分子) } double Jifen(double a,double b) { double h,r=1; double fx; double x; int i; double sum=0; h=fabs(a-b)/100; x=a; for(i=0;i<100;i++) { fx=f (x+i*h+h/2, r); sum=sum+fx; } return sum*h; } main() { double a; double b; double x= 3.0,fx,Abel,diff,h=0.01; a=2; b=3; diff = FordDiff(x, h, func); //微分 printf("FordDiff : %lf\n",diff); fx=Jifen(a,b); printf("Ji Fen Y=%f\n" ,fx); Abel = -1/3.14*fx; printf("Abel : %1f\n",Abel); } 如上所列,目前 我用自己的寫法 下去將前差微分項 放入分子 取代1 但目前 自己修改的結果 寫法都錯誤 無法跑出 正確的結果 在麻煩 版友們 幫我看看 該如何修改寫出 感恩~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ※ 編輯: freeflysky 來自: 140.116.16.80 (05/15 22:18)

05/15 23:39, , 1F
可能須要注意 sqrt 的引數不為負數
05/15 23:39, 1F
文章代碼(AID): #1HavIoCJ (C_and_CPP)
文章代碼(AID): #1HavIoCJ (C_and_CPP)