作者agody (講不聽)
看板Fortran
標題Re: [問題] 關於微分的寫法
時間Thu Jun 4 00:04:45 2009
※ 引述《dana79810 (kicala)》之銘言:
: ※ 引述《agody (講不聽)》之銘言:
: : 隨手寫的,不知道有沒有錯
: : program main
: : external y
: : call diff_1st(y,1,f)<---後面(y,l,f) 為什麼和下面附程式名子的不一樣?
: 是有其他的意釋嗎?
你去查一下external的函數使用方法
我可以任意給y,只要格式對,diff_1st中的fun就會去對到y subroutine
: : print *,f
: : end
: : subroutine diff_1st(fun,x,f)
: : external fun
: : dx = 1
: : k=1
: : f_old = (fun(x+dx)-fun(x-dx))/(2*dx)
: : dx = dx/2
: : do while(k) <--K是? 是 do while( K>0 )作回圈的意釋嗎?
k=1 true 迴圈
k=0 f 結束
: : f_new = (fun(x+dx)-fun(x-dx))/(2*dx)
: : dx = dx/2
: : if(f_new.eq.f_old) k = 0
: : f_old = f_new
: : end do
: : f = f_new
: : return
: : end
: : function y(x) <---哪一個步驟是將值帶入?
diff_1st中所有fun的函數
: : y = x**3 + x**2 - x + 3
: : return
: : end
: 因為我不太懂陣列的運用 ,所以有很多問題..請各位板大指點!!
: orz
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.126.120.172
1F:推 dana79810:謝謝唷!!! 我了解了 06/10 09:45