M. T. Homer Reid MIT Home Page
Physics Problems Research teaching My Music About Me Miscellany


A GUI Tool For Investigating The Parameter Dependence Of Definite Integrals

April 26, 2008

A lot of times it happens that you have a definite integral, depending on one or more external parameters, and you would like to see how the value of the integral varies as you vary those parameters. For example, consider the function

What does this integral look like as a function of the parameter M? There are two approaches to this question. One is actually to sit down and put a little thought into it. This, however, gets to be a hassle, especially on those days when you really just can't be bothered to think. In such cases it is convenient to be able to fall back on the second, no-actual-brainpower-required solution, which I call The Grinter, which I think is short for "graphical integrator."

 % grinter 

I think the GUI is pretty self-explanatory. You can have up to three numerical parameters and up to three nested integrals. You can enter arbitrary numbers, or -infinity and infinity, in the boxes for lower and upper integration bounds. You can save the data to a file with a name of your choosing. You can use logarithmic scales for either or both axes. You can tweak the numerical integration parameters. Once you have configured your choices, clicking the Go button will pop up a plot of your output:

Download The Source Code


To build the code you will need FLTK (including FLUID) and the GSL. To run it you will also need gnuplot. If anybody is actually reading this and has issues getting the software to build and/or run, let me know.

How It Works

Basically, the program just captures the user's input from the GUI window, writes out a little C program invoking the GSL numerical integration routines (with the character strings entered in the Integrand: boxes copied verbatim to be executed as C expressions), compiles and executes the little C program, and then invokes gnuplot to plot the results. There is no error checking at any step, so if you click Go and nothing happens then it could be that (a) the program didn't compile, maybe because you have a typo in your integrand expression (or the expression used a symbol that you didn't declare as a parameter or a variable of integration), or (b) the program compiled but the numerical integrator failed, maybe because your integral diverged, or (c) some other reason.

The GRINTER, by Homer Reid
Last Modified: 11/16/16