Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
module integration_library
implicit none
contains
function calculatex (x)
double precision :: calculatex
double precision, intent (in) :: x
calculatex = x **4 * log(x + (x**2 + 1)**0.5 )
end function
function area (y1,y2,dx)
double precision :: area
double precision, intent (in) :: y1,y2,dx
area = ((y1 + y2) * dx) / 2.0
end function
end module integration_library
program integration
use integration_library, only:calculatex,area
implicit none
double precision :: a,b,r,y1,y2,dx
integer :: i,n
10 format(a,1x,f20.10)
read (*,*) a
read (*,*) b
read (*,*) n
dx = (b-a) / n
r = 0
do i=1,n
y1 = calculatex (a + ((i-1) * dx))
y2 = calculatex (a + (i * dx))
r = r + area(y1,y2,dx)
end do
write(*,10) 'area =', r
end program
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more