In general one should distinguish three steps for such a task:
a) choosing a discrete approximation to the problem that can be handled by a machine that has a finite memory only. Such algorithms are explained in the literature of numerical mathematics. In this case (numerical approximation to an integral) you could look up e.g. Gauss quadrature or - somewhat more elementary - the Simpson rule.
c) a concrete implementation in a programming language that takes in parameters and spits out numbers. You can find some implementations in C++ in the book Numerical Recipes (people here may crucify me for recommending this book, because there are many over-simplifications and misunderstandings in it. But I think it is still a very good introduction to the basic ideas and algorithms, although professionals need something else, for sure.)
What happended to b) ?
Well, step b) would be a description of a concrete algorithm for the approximation from step a) in a platform-agnostic way (on a higher level of abstraction that a concrete implementation), so that one can implement the algorithm in whatever programming language that is appropriate (including Matlab, Sage, Mathematica). This is usually neglected however in the literature, so that you will have to do it yourself. But a book like "Numerical Recipes" should be a good start.