Graph

program prog1
  implicit none
  real(8):: a, b
  integer:: N
  integer:: i
  real(8):: dx, S, x
  real(8):: getFval
!
  print '(A$)', 'Input a, b, N: '
  read (*, *) a, b, N    !!!! 積分区間の上限と下限と分割数を入力する
!
  dx = (b - a)/dble(N)
!
  S = getFval(a)*0.5d0
  do i = 1, N - 1
    x = a + dble(i)*dx
    S = S + getFval(x)
  end do
  S = S + getFval(b)*0.5d0
  S = S*dx
  print *, S
!
  stop
end program prog1
!
function getFval(x) result(y)
  implicit none
  real(8):: x, y
  y = x*x*x       !!!! 被積分関数に応じて、この行を変更する
  return
end function getFval
seminar/数値積分のプログラム.txt · 最終更新: 2009/02/03 20:24 by kimi
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0