integrals Module

module for computing integrals


Used by

  • module~~integrals~~UsedByGraph module~integrals integrals program~test_integrals test_integrals program~test_integrals->module~integrals

Functions

public function trapz(x, y) result(Int)

Aproximates the integral of the function given a set of points: using the trapezoidal rule. The points do not need to be linearly spaced along the integration domain.

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: x(0:)

Array containing the abscissas of the points

real, intent(in) :: y(0:)

Array containing the ordinates of the points

Return Value real

Numerical aproximation to the integral

public function quad_trapz(f, a, b, h_in) result(Int)

Approximates the integral: using the trapezoidal rule on a linearly spaced set of points.

Arguments

Type IntentOptional Attributes Name
public function f(x) result(y)

Function to be integrated

Arguments
Type IntentOptional Attributes Name
real, intent(in) :: x

independent variable

Return Value real

dependent variable

real, intent(in) :: a

Lower limit of integration

real, intent(in) :: b

Upper limit of integration

real, intent(in) :: h_in

Approximated size of the intervals used by the trapezoidal rule.

Return Value real

Numerical approximation to the integral

public function quad_simpson(f, a, b, h_in) result(Int)

Approximates the integral: using Simpson's rule on a linearly spaced set of points.

Arguments

Type IntentOptional Attributes Name
public function f(x) result(y)

Function to be integrated

Arguments
Type IntentOptional Attributes Name
real, intent(in) :: x

independent variable

Return Value real

dependent variable

real, intent(in) :: a

Lower limit of integration

real, intent(in) :: b

Upper limit of integration

real, intent(in) :: h_in

Approximated size of the intervals used by the trapezoidal rule.

Return Value real

Numerical approximation to the integral

public function quad(f, a, b, h_in, method) result(Int)

Approximates the integral: using some integration method on a linearly spaced set of points.

Arguments

Type IntentOptional Attributes Name
public function f(x) result(y)

Function to be integrated

Arguments
Type IntentOptional Attributes Name
real, intent(in) :: x

independent variable

Return Value real

dependent variable

real, intent(in) :: a

Lower limit of integration

real, intent(in) :: b

Upper limit of integration

real, intent(in) :: h_in

Approximated size of the intervals used by the trapezoidal rule.

character(len=*) :: method

Method of integration to be used, can be either "Trapezoidal" or "Simpson"

Return Value real

Numerical approximation to the integral