How to Design Programs: An Introduction to Computing and Programming
Applying mathematics to real-world problems requires programs that implement mathematical functions. In many cases, the
programs also employ functions that consume and produce functions. Mathematics is therefore a great starting point for
practicing programming with functions and, more generally, for creating abstract functions.
The first subsection covers sequences and series, a key element of mathematics. The second section discusses integration,
which relies heavily on series. Finally, the third section introduces function differentiation.
Sequences and Series
In pre-algebra and algebra, we encounter
(also known as progressions) of numbers. Here are three examples:
0, 2, 4, 6, 8;
1, 3, 5, 7, 9;
5, 10, 15, 20, 25.
The first two enumerate the first five even and odd natural numbers, respectively; the last one lists the first five positive
integers, evenly divisible by 5. Sequences can also be infinite:
0, 2, 4, 6, 8,
1, 3, 5, 7, 9,
5, 10, 15, 20, 25,
Following mathematical tradition, infinite sequences end in ``
'' and the reader must determine how to find more of the
terms in the sequence.
One way to understand sequences of numbers, especially infinite ones, is to match them up with an enumeration of the
natural numbers. For example, the even and odd (natural) numbers match up like this:
It is easy to see from this table that every even number is 2 ·
for its index
and that an odd number is 2 ·
Both statements can be translated into simple Scheme functions:
..How%20to%20Design%20Programs/curriculum-Z-H-29.html (1 of 13) [2/5/2008 4:51:10 PM]