# Numerical integration of a function whose expression is unknown

I want to compute the value of an integral of a function.

This function, however, is not given by a formula, say $f(x) \: \forall x \in [0,1]$, but is only known through its values on some given points, say $f \left(\frac{k}{n} \right) \: \forall k \in \{0,\cdots,n\}$. (is the name for that scattered data ?)

How should I do so ? I don't want to implement a quadrature method by hand (I know how to do so in a basic way). Methods refering to a scientific library would be prefered (e.g. GSL).

• Welcome to SciComp Exchange. What software are you using (or planning to use) for this integration? – nicoguaro Apr 24 '15 at 17:06
• @nicoguaro I am coding in Fortran right now, but I have knowledge of Matlab, Scilab and some other maths tools. – bela83 Apr 25 '15 at 0:54

This function, however, is not given by a formula, say $f(x)$ $\forall{x}\in[0,1]$, but is only known through its values on some given points, say $f(k/n)$ $\forall{k}\in{0,⋯,n}$. (is the name for that scattered data ?)
In general, if you have data as collections of points $(x_{k}, f(x_{k})$, the absolute simplest method of integrating the "curve" through those points (there are many such curves) is to assume a linear interpolant between adjacent points, which gives you a trapezoidal rule. As far as I know, the trapezoidal rule is not in GSL (or at least, not in the numerical integration section). However, there are subroutines available in some libraries or software packages; trapz & cumtrapz in MATLAB come to mind. At worst, a trapezoidal rule wouldn't be onerous to implement by hand.