Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module functions
- contains
- function f(x)
- implicit none
- real :: f
- integer,intent(in) :: x
- f = EXP(real(x))
- end function
- end module
- program trapezio
- use functions
- implicit none
- integer :: i, n, b, a
- real :: sumation, mean, deltax, integral
- ! The value of the integral using the trapezium rule can be found using
- ! integral = (b - a)*((f(a) +f(b))/2 + sumation_1_n-1 )/n
- write(*,*) "type the limits b, a and the number of intervals"
- read *, b, a, n
- deltax = real(b - a)/real(n)
- mean = (f(a) + f(b))/2
- sumation = 0
- do i = 1, n-1
- sumation = sumation + f(i)
- end do
- integral = deltax*(mean + sumation)
- write (*,*) "the value of the integral using the trapezoidal method is", integral
- end program trapezio
Advertisement
Add Comment
Please, Sign In to add comment