I am using Microsoft Visual Studio with Intel Fortran and totally new to this coding platform. If my question is not worthy enough to put here, I ask for the apology in advance but I really need the solution to this problem. I am needed to integrate a large number of trigonometric expressions (approx. 4860). I am using the QUADPACK library and following code:
program integral
real ( kind = 4 ), parameter :: a = 0.0E+00
real ( kind = 4 ) abserr
real ( kind = 4 ) b,x
real ( kind = 4 ), parameter :: epsabs = 0.0E+00
real ( kind = 4 ), parameter :: epsrel = 0.001E+00
real ( kind = 4 ), external :: f2
integer ( kind = 4 ) ier
integer ( kind = 4 ), parameter :: key = 6
integer ( kind = 4 ) neval
real ( kind = 4 ), parameter :: r4_pi = 3.141592653589793E+00
real ( kind = 4 ) result1
real ( kind = 4 ), parameter :: true = 0.06278740E+00
b = r4_pi
call qag ( f2, a, b, epsabs, epsrel, key, result1, abserr, neval, ier )
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'QAG_TEST'
write ( *, '(a)' ) ' Test QAG'
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Integrand is COS(100*SIN(X))'
write ( *, '(a,g14.6)' ) ' Integral left endpoint A = ', a
write ( *, '(a,g14.6)' ) ' Integral right endpoint B = ', b
write ( *, '(a,g14.6)' ) ' Exact integral is ', true
write ( *, '(a,g14.6)' ) ' Estimated integral is ', result1
write ( *, '(a,g14.6)' ) ' Estimated integral error = ', abserr
write ( *, '(a,g14.6)' ) ' Exact integral error = ', true - result
write ( *, '(a,i8)' ) ' Number of function evaluations, NEVAL = ', neval
write ( *, '(a,i8)' ) ' Error return code IER = ', ier
end program integral
function f2(x)
implicit none
real ( kind = 4 ) f2
real ( kind = 4 ) x
f2=COS(100*SIN(X))
end function
From the above code, I can easily find the integral of a single expression. But in my case, I have an array (18*270) containing all the elements as a mathematical expression. I want to call them one by one and integrate them. Please suggest me how to deal with it. Thank you.