Re: [問題] 如何用辛普森積分法解這題?
※ 引述《sawwas (saw)》之銘言:
: Q: 將 e^(-x^2) 用辛普森積分法從 0 積到 3
: ( 限定用Fortran語法編譯 )
: 因為我從來沒學過Fortran 所以只好來此求助
: 拜託各位大大了~~~
切1000格
integer :: i
real*8 :: y
real*8 :: x
real*8 :: dx
real ll
real sum
dx = 3.0/(1000)
ll = 4.0
sum = 1.0*exp(-(dx*1)**2 )*dx
do i = 2, i=999
x = i*dx
y = exp(-x**2 )
sum = ll*y*dx + sum
ll = 6.0 - ll
enddo
sum = 1.0*exp(-(dx*1000)**2 )*dx + sum
sum = sum/3.0
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.216.81.152
推
05/29 17:34, , 1F
05/29 17:34, 1F
→
05/29 17:35, , 2F
05/29 17:35, 2F
→
05/29 17:35, , 3F
05/29 17:35, 3F
討論串 (同標題文章)
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章