NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
simps Interface Reference

Routines for integration of sampled values or functions by using Simpson rule. More...

Detailed Description

Routines for integration of sampled values or functions by using Simpson rule.

The use of this routine is simlar to the use of trapz. For integration of a real-valued and complex-valued function f the following calls are valid

call simps(f) ! Using 100 equispaced points between 0 and 1
call simps(f, a, b) ! Using 100 equispaced points between a and b
call simps(f, a, b, N) ! Using N equispaced points between 0 an 1
call simps(f, x) ! Using evaluations on values of array x

Here:

Parameters
[in]fis a real or complex function
[in]a(real) Lower limit of integration
[in]b(real) Upper limit of integration
[in]N(integer) Number of equally-spaced points to use
[in]x(real, array) Points where the function will be evaluated

For sampled values it accepts several input formats,

call simps(y) ! Using values in array y, corresponding to x ∈ [0,1]
call simps(y, a, b) ! Using values in array y, corresponding to x ∈ [a,b]
call simps(y, dh) ! Using values in y, for x values equispaced in dh
call simps(y, x) ! Using values in y, corresponding to x

Here:

Parameters
[in]yis a real or complex array
[in]a(real) Lower limit of integration
[in]b(real) Upper limit of integration
[in]dh(real) Space between points in the x-axis
[in]x(real, array) Points where the function is evaluated

Example:

real(dp) :: Integ1
intrinsic dsin
integ1 = trapz(dsin, zero, m_pi)
print "(A)", '\int \sin(x) dx = '//str(integ1)//" (Difference="//str(abs(2 - integ1))//")"
! \int \sin(x) dx = 1.999832163894 (Difference=0.000167836106)

The documentation for this interface was generated from the following file: