Recursive Functions and Procedures in GAUSS and MATHEMATICA
A recursive function or procedure is one which calls itself. The famous Bellman Equation of dynamic programming is an example of a recursive algorithm widely employed in economic analysis.[1] To illustrate the concept, imagine a simulated termite wandering around on your screen. You have scattered bits of wood around your screen at random, within a grid of "patches." There are more "patches" than chips, so some of the patches are empty. The termite moves in random directions and in random increments around the whole screen. When the termite runs into a "patch" with some chips, it picks one up and moves off again. If there are chips in the "patch," the termite simply continues until it comes to a "patch" with no chips in it. The termite deposits the chip and the process terminates. As long as there are more "patches" than chips, some "patches," at least, must be empty, and the process must eventually terminate. Such a termination rule, which the algorithm is capable of attaining, must always begin a recursive procedure. Here the algorithm "search" calls itself over and over until its termination condition is satisfied.
[1] See A. K Dixit, Optimization in Economic Theory, 2nd ed., New York: Oxford University Press, 1990, Chapter 11, pp. 162 - 180. N. L. Stokey and R. E. Lucas have written a whole book on such methods: Recursive Methods in Economic Dynamics, Cambridge: Harvard University Press, 1989.