Skip to main content
Logo image

Chapter 5 Step functions

Section 5.1 Concept

Example 5.1.1. Inflating a raft.

You bring an inflatable raft on a trip to the lake, along with a portable air pump to inflate it. The air pump has three settings:
Notice that the specification for each of the three settings is given in volume-per-unit-time, so these are inflation rates.
You run the pump at medium for one minute, but it’s taking too long so you bump it up to high. After two minutes on high, the raft is nearly inflated but the pump seems like it’s getting a bit hot as it works to counter-act the tendency of the raft to want to deflate, so you switch it to low for one more minute before turning it off.
Graph modelling output of an air pump with three settings.
A rate-versus-time graph, with the vertical axis in metres-cubed-per-minute, and the horizontal axis in minutes. The graph is a piecewise function, with each piece a horizontal line segment. The graph begins at rate \(0\) for negative time, and then
  • a one-minute period at rate \(0.5\text{,}\)
  • followed by a two-minute period at rate \(0.75\text{,}\)
  • followed by a one-minute period at rate \(0.25\text{,}\)
and finally the graph returns to rate \(0\) forever more.
Figure 5.1.2. Graph modelling output of an air pump with three settings.
The model rate function graphed in FigureΒ 5.1.2 is an example of a step function.

Definition 5.1.3. Step function.

A function that β€œsteps” between constant values on non-overlapping intervals.
A function can only take on one output value at any given input value, which is why we have an open circle at the endpoint of each line segment in the graph in FigureΒ 5.1.2. For example, if we call that inflation rate function \(r\text{,}\) then \(r(3) = 0.25\) but \(r(2.9999) = 0.75\text{.}\) Of course, this function is just a model of the behaviour of the air pump described in ExampleΒ 5.1.1 β€” we could have put open circles at the beginnings of the line segments and closed ones at the ends instead, and it wouldn’t affect our analysis of the inflation of the raft.
To describe a step function, we use piecewise notation to specify the constant output values on different subdomains.

Example 5.1.4. Describing a step function.

Here is the graph of another step function.
Graph of an example step function.
The graph of a step function is drawn on a set of \(tq\)-axes. The initial step runs along the negative horizontal axis at height \(0\text{,}\) and ends in an open endpoint at the origin. The next four steps are horizontal line segments with a closed endpoint at the left end and an open endpoint at the right end, each beginning at the \(t\)-value where the previous ended:
  • The first of these steps is at height \(q = 1\) and runs for one unit of \(t\text{.}\)
  • The second is at height \(q = 2\) and also runs for one unit of \(t\text{.}\)
  • The third is at height \(q = 3\) and has its endpoint at \(t = \pi\text{.}\)
  • The fourth is at height \(q = \sqrt{2}\) and has its endpoint at \(t = 4.5\text{.}\)
The final step again runs along the horizontal axis, beginning with a closed endpoint at \(t = 4.5\text{,}\) but with no endpoint.
Figure 5.1.5. An example step function.
There is no single constant value or formula that describes the function’s output values at every possible input value, so we describe the function’s output values using different output values on different subdomains.
\begin{equation*} f(t) = \begin{cases} 0 \amp t \lt 0 \\ 1 \amp 0 \le t \lt 1 \\ 2 \amp 1 \le t \lt 2 \\ 3 \amp 2 \le t \lt \pi \\ \sqrt{2} \amp \pi \le t \lt 4.5 \\ 0 \amp t \ge 4.5 \end{cases} \end{equation*}
Suppose we wanted to determine the output value \(f(\sqrt{3})\) without the graph in front of us. We would first scan the subdomains in the right column, and notice that the input \(t = \sqrt{3}\) falls into the subdomain \(1 \le t \lt 2\text{.}\) Matching up this subdomain with its specified output value, we find that \(f(\sqrt{3}) = 2\text{.}\)
The simplest situation to deal with is a step function that β€œsteps” at regular intervals.

Definition 5.1.6. Regular step function.

A step function whose domain can be split into equal-length intervals so that the β€œsteps” in output value only occur at boundaries between these intervals.
The step function in ExampleΒ 5.1.4 is not regular β€” the steps in output value from \(1\) to \(2\) and from \(2\) to \(3\) both occur after intervals of length \(1\text{,}\) but the next two steps in output value occur after intervals of length greater than \(1\text{.}\) Because the irrational number \(\pi\) is involved in these longer two interval lengths, there is no way to subdivide all these intervals into equal-length intervals so that output-value changes only occur at interval boundaries.
On the other hand, the air pump model in ExampleΒ 5.1.1 is regular because we can split the middle interval in half, and then changes in output-value still only occur at boundaries of these length-\(1\) intervals.
Graph modelling output of an air pump with three settings.
The rate-versus-time graph of FigureΒ 5.1.2 is reproduced, except that the step at rate \(0.75\) of duration \(2\) is split by an extra β€œendpoint” in the middle, so that it can instead be regarded as two separate steps, each of duration \(1\text{.}\)
Figure 5.1.7. Graph modelling output of an air pump with three settings.

Section 5.2 Accumulation for a stepped rate function

Subsection 5.2.1 Calculation pattern

When a rate function is known to be constant, computing accumulation is easy:
\begin{equation*} \text{amount} = \text{rate} \times \text{duration} \text{.} \end{equation*}
When a quantity changes with a rate function that can be modelled by a step function, then the rate function is not constant over its entire domain because it is not always the same rate value for all time. However, a stepped rate function is constant over specific subdomains, so we can still apply the above formula on each of those subdomains and then total up all of those partial accumulations.
Example 5.2.1. Inflated raft.
For the situation described in ExampleΒ 5.1.1, how much air has been pumped into the raft? To answer this question, we will split the inflation time period up.
During the first minute when the pump is run on the medium setting, pumping air at a rate of 0.5 m3⁄min for one minute accumulates
\begin{equation*} (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min}) = 0.5 \unitsp \mathrm{m}^3 \end{equation*}
of air in the raft.
Over the next two minutes, when the air pump is on the high setting, we accumulate an additional
\begin{equation*} (0.75 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min}) = 1.5 \unitsp \mathrm{m}^3 \end{equation*}
of air in the raft.
Finally, over the final minute on the low setting, we accumulate an additional
\begin{equation*} (0.25 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min}) = 0.25 \unitsp \mathrm{m}^3 \end{equation*}
of air in the raft.
The total accumulation of air in the raft is the total of the calculations.
\begin{align*} \text{TOTAL} \amp = (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.75 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.25 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min})\\ \amp = (0.5 + 1.5 + 0.25) \unitsp \mathrm{m}^3 \\ \amp = 2.25 \unitsp \mathrm{m}^3 \text{.} \end{align*}
Remember that we can have a rate function where the independent variable represents something other than time.
Example 5.2.2. Accumulation of cost.
You are ordering a quantity of saffron, a very expensive spice, for your bulk food preparation business. The supplier offers a discount scheme based on the amount you order:
  • The first 500 g ordered is priced at $3.00 per gram.
  • Any additional amount ordered above 500 g is priced at $2.75 per gram, for orders up to 1 kg total. For example, if an order of 600 g is placed, then only the additional 100 g quantity is charged at $2.75 per gram, while the β€œinitial” quantity of 500 g is still charged at $3.00 per gram.
  • Any additional amount above 1 kg is priced at $2.50 per gram.
The pricing model can be considered a rate function, where the inputs are in units of grams, and the outputs are in units of dollars-per-gram.
Graph for a saffron pricing model.
A rate-versus-mass graph, with the vertical axis in dollars-per-gram and the horizontal axis in grams. The function graphed is a step function. The initial step runs along the negative horizontal axis, ending in a closed endpoint at the origin. The next two steps each run for a β€œduration” of \(500\) grams, each beginning with an open endpoint at the horizontal location where the previous step ended, and ending with a closed endpoint. The first such step runs at height \(3\) and the second at height \(2.75\text{.}\) The final step begins with an open endpoint at the horizontal location where the previous step left off and runs forever more at height \(2.5\text{.}\)
Figure 5.2.3. Graph for a saffron pricing model.
In this pricing model, the total β€œaccumulated” cost of your order of 1.2 kg is
\begin{align*} \text{COST} \amp = (3.00 \unitsp \$ / \mathrm{g}) \times (500 \unitsp \mathrm{g})\\ \amp \phantom{=} + (2.75 \unitsp \$ / \mathrm{g}) \times (500 \unitsp \mathrm{g})\\ \amp \phantom{=} + (2.50 \unitsp \$ / \mathrm{g}) \times (200 \unitsp \mathrm{g})\\ \amp = \$ 1500 + \$ 1375 + \$ 500 \\ \amp = \$ 3375 \text{.} \end{align*}

Subsection 5.2.2 Geometric interpretation

Consider what the calculations in ExampleΒ 5.2.1 represent on the graph of the inflation rate function. On each subdomain, we used the constant-rate accumulation formula
\begin{equation*} \text{amount} = \text{rate} \times \text{duration} \text{.} \end{equation*}
The rate represents the height of the graph on that particular subdomain, while the duration represents the length of time that this rate was in effect. Geometrically, the product of a height and a length represents the area of a rectangle:
\begin{equation*} \text{area} = \text{height} \times \text{length} \text{.} \end{equation*}
So each partial accumulation calculation in ExampleΒ 5.2.1 corresponds to an area of a rectangle related to the graph of the stepped rate function. Let’s see exactly how.
First, suppose we actually turned the air pump off after the first minute of running on the medium setting. The accumulation formula
\begin{equation*} \text{air accumulation} = (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min}) \end{equation*}
corresponds to an area calculation for a rectangle of height \(0.5\) and length \(1\text{.}\)
Graph modelling output of an air pump for one minute.
A rate-versus-time graph, with the vertical axis in metres-cubed-per-minute, and the horizontal axis in minutes. The function graphed is a step function, but with only three levels. The initial level runs along the negative horizontal axis, ending in an open endpoint at the origin. The next step runs at height \(0.5\) for a one-minute duration, beginning with a closed endpoint and ending in an open endpoint. The final step runs from that horizontal location along the positive horizontal axis, beginning with a closed endpoint but with no endpoint. Finally, the rectangle formed by the middle step as top side and the corresponding width along the horizontal axis as bottom side is shaded in.
Figure 5.2.4. Running the air pump on medium for one minute.
Now let’s take into account the additional two minutes running on high. The accumulation formula
\begin{equation*} \text{air accumulation} = (0.75 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min}) \end{equation*}
corresponds to an area calculation for a rectangle of height \(0.75\) and length \(2\text{.}\)
Graph modelling output of an air pump for another two minutes.
A rate-versus-time graph, with the vertical axis in metres-cubed-per-minute, and the horizontal axis in minutes. The function graphed is a step function, but with only four levels. The initial level runs along the negative horizontal axis, ending in an open endpoint at the origin. The next two steps each begin with a closed endpoint at the horizontal location where the previous step ended, and end in an open endpoint, with the first such step running at height \(0.5\) for a one-minute duration, and the second running at height \(0.75\) for a two-minute duration. The final step runs along the positive horizontal axis, beginning with a closed endpoint at the horizontal location where the previous step ended, but with no endpoint. Finally, each of the middle two steps forms a rectangle where the step is the top side and the corresponding width along the horizontal axis is the bottom side, and these two rectangles are shaded in, with the second rectangle a different color to highlight it as β€œnew” (relative to the shaded rectangular area in FigureΒ 5.2.4).
Figure 5.2.5. Running the air pump on high for another two minutes.
Finally, the accumulation formula
\begin{equation*} \text{air accumulation} = (0.25 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min}) \end{equation*}
for the final minute running on low corresponds to an area calculation for a rectangle of height \(0.25\) and length \(1\text{.}\)
Graph modelling output of an air pump for another one minute.
A rate-versus-time graph, with the vertical axis in metres-cubed-per-minute, and the horizontal axis in minutes. The function graphed is a step function with five levels. The initial level runs along the negative horizontal axis, ending in an open endpoint at the origin. The next three steps each begin with a closed endpoint at the horizontal location where the previous step ended, and end in an open endpoint, where:
  1. The first such step runs at height \(0.5\) for a one-minute duration.
  2. The second runs at height \(0.75\) for a two-minute duration.
  3. The third runs at height \(0.25\) for a one-minute duration.
The final step runs along the positive horizontal axis, beginning with a closed endpoint at the horizontal location where the previous step ended, but with no endpoint. Finally, each of the middle three steps forms a rectangle where the step is the top side and the corresponding width along the horizontal axis is the bottom side, and these three rectangles are shaded in, with the third rectangle a different color to highlight it as β€œnew” (relative to the shaded rectangular areas in FigureΒ 5.2.5).
Figure 5.2.6. Running the air pump on high for the final minute.
For the total accumulation, we added up the results of these three calculations. Graphically, the total accumulation corresponds to the total area of the rectangles formed between the stepped rate function’s levels and the horizontal axis.
Graph modelling total accumulation pumped air.
The graph of FigureΒ 5.2.6 is reproduced, but now all three rectangular areas are shaded the same colour to identify them as one combined area.
Figure 5.2.7. Total accumulation over the time period.
Warning 5.2.8.
We talk above about accumulation corresponding to area, but the results of each of our accumulation calculations in ExampleΒ 5.2.1 are in units of \(\mathrm{m}^3\text{,}\) not \(\mathrm{m}^2\) β€” why is that?
It is important to maintain a distinction between
  • the actual physical quantity whose accumulation we are determining (in ExampleΒ 5.2.1, this is a volume of air in units of \(\mathrm{m}^3\))
  • the graphical area formed by creating rectangles under the different levels of the step function.
We are making a graphical connection between the two product calculations
\begin{gather*} \text{amount} = \text{rate} \times \text{duration} \\ \text{area} = \text{height} \times \text{length} \end{gather*}
by interpreting each rate value as a height and each time duration as a length on the rate graph. Through this correspondence between the two formulas above, the magnitudes of accumulation and graphical area will be the same, but their units of measurement will not coincide.
Example 5.2.9.
On a car trip from Camrose to Wetaskiwin, it takes the driver 6 min at the posted Camrose city speed limit of 50 km⁄h to get out onto the highway, then 24 min at the posted highway speed limit of 100 km⁄h to reach Wetaskiwin, and another 9 min at the posted Wetaskiwin city speed limit of 50 km⁄h to reach the final destination.
With this model, our rate function is stepped.
Graph of a rate-of-travel model.
A rate-versus-time graph, with the vertical axis in kilometres-per-hour, and the horizontal axis in hours. The function graphed is a step function, with five levels. The initial level runs along the negative horizontal axis, ending in an open endpoint at the origin. The next three steps each begin with a closed endpoint at the horizontal location where the previous step ended, and end in an open endpoint, where:
  1. The first such step runs at height \(50\) for a duration of \(0.1\text{.}\)
  2. The second runs at height \(100\) for a duration of \(0.4\text{.}\)
  3. The third runs at height \(50\) for duration of \(0.15\text{.}\)
The final step runs along the positive horizontal axis, beginning with a closed endpoint at the horizontal location where the previous step ended, but with no endpoint. Finally, each of the middle three steps forms a rectangle where the step is the top side and the corresponding width along the horizontal axis is the bottom side, and these three rectangles are shaded in,
Figure 5.2.10. Graph of a rate-of-travel model.
(Note that minutes have been converted into hours for the graph.)
Computing the total distance travelled is the same as calculating the total area of the three rectangles in FigureΒ 5.2.10:
\begin{align*} \text{TOTAL DISTANCE} \amp = (50 \unitsp \mathrm{km} / \mathrm{hr}) \times (0.1 \unitsp \mathrm{hr})\\ \amp \phantom{=} + (100 \unitsp \mathrm{km} / \mathrm{hr}) \times (0.4 \unitsp \mathrm{hr})\\ \amp \phantom{=} + (50 \unitsp \mathrm{km} / \mathrm{hr}) \times (0.15 \unitsp \mathrm{hr})\\ \amp = (5 + 40 + 7.5) \unitsp \mathrm{km} \\ \amp = 52.5 \unitsp \mathrm{km} \text{.} \end{align*}
Remark 5.2.11.
Keep in mind that the stepped rate function in ExampleΒ 5.2.9 is a simplified model. In reality, a car cannot change its rate of travel instantaneously, and so our rate graph should have periods of increasing speed (that is, acceleration) and periods of decreasing speed (that is, deceleration). Moreover, it is unlikely the car was travelling at exactly 50 km⁄h during the city portions of the trip, or at exactly 100 km⁄h during the highway portion β€” in reality there would have been dips and rises in the rate graph, as the car went up or down hills, around corners, or was stuck behind or pulled out to pass slower-moving vehicles. However, often a simplified model is good enough, and trying to take into account all of the little variations in velocity during the trip might be too complicated for the simple purpose of estimating the distance travelled.
In fact, we will learn in the next chapter how estimating accumulation using simplified models involving stepped rate functions can actually help us to calculate accumulation exactly for more complicated models.
Checkpoint 5.2.12. Accumulation of cost.
In ExampleΒ 5.2.2, we analyzed a purchasing scenario with a rate function describing variation in cost per unit mass, (whereas our other examples have all involved variation per unit time). Do you see how the total cost calculation in that example corresponds to a sum of areas of rectangles on the rate function graph?

Subsection 5.2.3 Oriented area

What if the rate is sometimes negative?
Example 5.2.13. Punctured raft.
One minute after inflating your raft (as in ExampleΒ 5.1.1), a previously patched leak begins leaking again at a rate of 0.2 m3⁄min, and three minutes pass before you notice, quickly slap a piece of tape over the leak, and turn the air pump back on to medium for two minutes. (We’ll assume in our simplified model that all of this happens instantaneously.)
How much air is in the raft now? We just have to repeat the calculation of ExampleΒ 5.1.1, but take into account the periods of air-loss and re-inflation.
\begin{align*} \text{TOTAL} \amp = (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.75 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.25 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min})\\ \amp \phantom{=} - (0.2 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (3 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min})\\ \amp = (0.5 + 1.5 + 0.25 - 0.6 + 1) \unitsp \mathrm{m}^3 \\ \amp = 2.65 \unitsp \mathrm{m}^3 \text{.} \end{align*}
Can we still interpret the calculation in ExampleΒ 5.2.13 as a sum of rectangle areas on the rate graph? While leaking air, the amount of accumulated air in the raft is decreasing, and so we should interpret the rate of air leakage as a negative rate of variance. The static period between the initial inflation and the start of the leakage could also be interpreted as a period with rate 0 m3⁄min.
\begin{align*} \text{TOTAL} \amp = (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.75 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min})\\ \amp \phantom{=} + (0.25 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min})\\ \amp \phantom{=} {\color{red} + (0 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (1 \unitsp \mathrm{min}) }\\ \amp \phantom{=} {\color{red} + (-0.2 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (3 \unitsp \mathrm{min}) }\\ \amp \phantom{=} + (0.5 \unitsp \mathrm{m}^3 / \mathrm{min}) \times (2 \unitsp \mathrm{min})\\ \amp = \bigl( 0.5 + 1.5 + 0.25 + 0 + (-0.6) + 1 \bigr) \unitsp \mathrm{m}^3 \\ \amp = 2.65 \unitsp \mathrm{m}^3 \text{.} \end{align*}
If we allow rectangles to be assigned negative area and also consider a line segment along the horizontal axis as a rectangle with height \(0\text{,}\) then the above calculation is still a sum of rectangle areas.
Graph modelling inflating, partially deflating, and re-inflating an air raft.
A rate-versus-time graph, with the vertical axis in metres-cubed-per-minute, and the horizontal axis in minutes. The function graphed is a step function, with eight levels. The initial level runs along the negative horizontal axis, ending in an open endpoint at the origin. The next six steps each begin with a closed endpoint at the horizontal location where the previous step ended, and end in an open endpoint, where:
  1. The first such step runs at height \(0.5\) for a one-minute duration.
  2. The second runs at height \(0.75\) for a two-minute duration.
  3. The third runs at height \(0.25\) for a one-minute duration.
  4. The fourth runs along the horizontal axis for a one-minute duration.
  5. The fifth runs at height \(-0.2\) for a three-minute duration.
  6. The sixth runs at height \(0.5\) for a two-minute duration.
The final step runs along the positive horizontal axis, beginning with a closed endpoint at the horizontal location where the previous step ended, but with no endpoint.
Of the six middle steps, each of the four at a positive height forms a rectangle where the step is the top side and the corresponding width along the horizontal axis is the bottom side. Additionally, the step at a negative height forms a rectangle where the step is the bottom side and the corresponding width along the horizontal axis is the top side. All five of these rectangles are shaded in, with the four extending above the horizontal axis shaded blue and the one extending below the horizontal axis shaded red.
Figure 5.2.14. Inflating and re-inflating an air raft.
Definition 5.2.15. Positively-oriented area.
If a function is positive on a domain, then the area bounded between the graph of the function and the horizontal axis over that domain is positively-oriented and we assign positive number to that area.
A diagram of a positively-oriented area under the graph of a function.
A graph is drawn on a set of \(xy\)-axes. The graph begins in the fourth quadrant and rises to a peak in the first quadrant, crossing the horizontal axis as is does so. The graph then descends to a trough in the fourth quadrant, again crossing the horizontal axis between the peak and the trough. Finally, the graph rises from that trough until it reaches the top edge of the diagram, once more crossing the horizontal axis between the trough and the apparent end of the graph.
The first two of the three points of intersection of the graph with the horizontal axis are plotted, and over the domain between those two points the graph is entirely above the horizontal axis. The region in the first quadrant that is bounded above by the graph and below by the horizontal axis is shaded in blue.
Figure 5.2.16. A positively-oriented area.
Definition 5.2.17. Negatively-oriented area.
If a function is negative on a domain, then the area bounded between the graph of the function and the horizontal axis over that domain is negatively-oriented and we assign a negative number to that area.
A diagram of a negatively-oriented area under the graph of a function.
A graph is drawn on a set of \(xy\)-axes. The graph begins in the fourth quadrant and rises to a peak in the first quadrant, crossing the horizontal axis as is does so. The graph then descends to a trough in the fourth quadrant, again crossing the horizontal axis between the peak and the trough. Finally, the graph rises from that trough until it reaches the top edge of the diagram, once more crossing the horizontal axis between the trough and the apparent end of the graph.
The last two of the three points of intersection of the graph with the horizontal axis are plotted, and over the domain between those two points the graph is entirely below the horizontal axis. The region in the fourth quadrant that is bounded below by the graph and above by the horizontal axis is shaded in red.
Figure 5.2.18. A negatively-oriented area.

Section 5.3 Sigma notation

Subsection 5.3.1 Summing patterns

In the examples in this section, total accumulation was calculated as a sum of products. The situation of calculating a sum where each term in the sum follows a pattern comes up a lot in mathematics, so mathematicians have developed a special notation for it.
Sigma notation.
If we write \(P(k)\) to mean a calculation formula or pattern in the variable \(k\text{,}\) then we can write
\begin{equation*} \sum_{k = 1}^n P(k) \end{equation*}
to represent the sum
\begin{equation*} P(1) + P(2) + P(3) + \dotsb + P(n) \text{.} \end{equation*}
The Greek letter \(\Sigma\) stands for β€œSum”, the variable \(k\) is called the index variable for the sum, and the β€œstart” and β€œend” values \(1\) and \(n\) are called the lower bound and upper bound, respectively, for the summation.
Note 5.3.1.
The Greek letter \(\Sigma, \sigma\) is called β€œsigma”, where \(\Sigma\) is the uppercase version and \(\sigma\) is the lower case version. This letter corresponds to the letter S in the English alphabet, hence its use to represent a Sum.
Example 5.3.2. Sum of squares.
Consider the sum-of-squares formula
\begin{equation*} 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 \text{.} \end{equation*}
Recognizing each term in the sum as a square number, we can express each term as the result of the pattern
\begin{equation*} P(k) = k^2 \end{equation*}
for increasing integer values of the variable \(k\text{:}\)
\begin{equation*} 1^2 + 2^2 + 3^2 + 4^2 + 5^2 + 6^2 + 7^2 + 8^2 + 9^2 + {10}^2 \text{.} \end{equation*}
Based on this pattern, we can compactly express the above sum of squares using Sigma notation:
\begin{equation*} \sum_{k = 1}^{10} k^2 \text{.} \end{equation*}
While we used the value \(k = 1\) as sort of a β€œdefault” start value in the definition of Sigma notation above, we can use any start value we like, according to the summation pattern we are trying to describe.
Example 5.3.3. Different starting value.
Here is another sum-of-squares formula:
\begin{equation*} 16 + 25 + 36 + 49 + 64 + 81 + 100 \text{.} \end{equation*}
Since this summation pattern begins at the square of \(4\text{,}\) our Sigma-notation version of this sum is
\begin{equation*} \sum_{k = 4}^{10} k^2 \text{.} \end{equation*}
Example 5.3.4. Summing a constant value.
Summing a constant value is, by definition, the same as multiplication (which is why we say β€œtimes”).
\begin{align*} \sum_{k = 1}^{6} 2 \amp = 2 + 2 + 2 + 2 + 2 + 2 \\ \amp = 6 \times 2 \\ \amp = 12 \end{align*}
Take care when counting an indexed collection: the number of objects is
\begin{equation*} (\text{ending index value}) - (\text{starting index value}) + 1 \text{.} \end{equation*}
The β€œ\(+ 1\)” is required because in the subtraction we have β€œtaken away” every object up to and including the one indexed by the β€œstarting index value,” but we actually want to include that β€œstarting” object in the collection being counted. For example, if we have a sum indexed from \(k = 1\) to \(k = n\text{,}\) then we are adding up \(n\) terms, not \(n - 1\) terms.

Subsection 5.3.2 Properties of Sigma notation

Keep in mind that calculating with Sigma notation is really just addition, so every algebra rule for addition can be applied to Sigma notation.
Example 5.3.6. Sum of evens.
Suppose we want to sum a collection of even numbers:
\begin{equation*} 2 + 4 + 6 + 8 + 10 \text{.} \end{equation*}
While there are variations of Sigma notation where the index variable may β€œstep” by more than \(1\text{,}\) we can avoid that by expressing each of our even numbers as \(2\) times a number that increases by only \(1\) from term to term:
\begin{equation*} 2 \cdot 1 + 2 \cdot 2 + 2 \cdot 3 + 2 \cdot 4 + 2 \cdot 5 \text{.} \end{equation*}
In Sigma notation, this sum can be expressed as
\begin{equation*} \sum_{k = 1}^{5} 2 k \text{.} \end{equation*}
However, we also know that a common factor can be factored out of a sum:
\begin{equation*} 2 (1 + 2 + 3 + 4 + 5) \text{.} \end{equation*}
This formula is \(2\) times a sum, so we can express it as \(2\) times a Sigma expression:
\begin{equation*} 2 \sum_{k = 1}^{5} k \text{.} \end{equation*}
Warning 5.3.8.
Only a constant may be factored out of Sigma notation β€” any expression involving the index variable \(k\) cannot be factored out, because if the sum were written out that variable part would be different from term to term and so would not actually be a common factor.
As well as factoring out of sums, we also know that we may perform a series of additions in any order and with any groupings we wish.
Example 5.3.9. Summing two patterns.
Consider the sum
\begin{equation*} 2 + 6 + 12 + 20 + 30 + 42 + 56 + 72 + 90 + 110 \text{.} \end{equation*}
It may not be obvious at first glance, but is the summation from ExampleΒ 5.3.2 with each term increased by its index:
\begin{equation*} (1^2 + 1) + (2^2 + 2) + (3^2 + 3) + \dotsb + (10^2 + 10) \text{.} \end{equation*}
In Sigma notation, this can be written
\begin{equation*} \sum_{k = 1}^{10} (k^2 + k) \text{.} \end{equation*}
But we would come to the same result if we added all the squares first, and then added to that result the sum of the extra bits:
\begin{equation*} (1^2 + 2^2 + 3^2 + \dotsb + 10^2) + (1 + 2 + 3 + \dotsb + 10) \text{.} \end{equation*}
We can write each of the bracketed Sigma expressions in Sigma notation separately:
\begin{equation*} \sum_{k = 1}^{10} k^2 + \sum_{k = 1}^{10} k \text{.} \end{equation*}
Example 5.3.11. Breaking up a sum.
Again consider the sum-of-squares pattern
\begin{equation*} 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 \text{.} \end{equation*}
We can put brackets around any portions of the sum without changing the result:
\begin{equation*} (1 + 4 + 9 + 16 + 25 + 36) + (49 + 64 + 81 + 100) \text{.} \end{equation*}
Aside: BEDMAS.
So this same sum that we expressed in ExampleΒ 5.3.2 using a single Sigma expression can be re-expressed using two Sigma expressions, if we had some particular reason for wanting to do so:
\begin{equation*} \sum_{k = 1}^{6} k^2 + \sum_{k = 7}^{10} k^2 \text{.} \end{equation*}

Subsection 5.3.3 Summing in Sage

Summation based on a pattern can be performed in Sage. The syntax is below.
	sum(pattern, variable, start, end)

For example, the summation
\begin{equation*} \sum_{k=1}^{5} 2 k + 1 \end{equation*}
becomes Sage input
	sum(2*k + 1, k, 1, 5)

However, remember that by default the only letter that Sage treats as a variable is x, so if we want to use k for our index variable as we’ve been doing in our Sigma notation, we have to first tell Sage that we want k to be treated as a variable.
Example 5.3.13. Summing in Sage.
Let’s try the example command above.
Checkpoint 5.3.14. Try it yourself.
Use the blank Sage cell below to compute the sum
\begin{equation*} \sum_{k = 1}^{17} k^2 \text{.} \end{equation*}
(If you’ve already evaluated the example Sage cell above, you won’t need the var('k') command.)

Section 5.4 Riemann sums

When we sum up the (oriented) areas of rectangles formed by a step function, the sum is called a Riemann sum.

Biographical Aside: Georg Friedrich Bernhard Riemann.

Definition 5.4.1. Riemann sum.

Suppose \(s(t)\) is a step function that takes on values
\begin{equation*} s(t) = \begin{cases} h_1 \amp t_0 \le t \lt t_1 \\ h_2 \amp t_1 \le t \lt t_2 \\ h_3 \amp t_2 \le t \lt t_3 \\ \amp \vdots \\ h_n \amp t_{n - 1} \le t \lt t_n \end{cases}\text{.} \end{equation*}
If we write \(\change{t_k}\) to represent the length of the subdomain \(t_{k - 1} \le t \lt t_k\) so that
\begin{equation*} \change{t_k} = t_k - t_{k - 1} \text{,} \end{equation*}
then the sum
\begin{equation*} \sum_{k = 1}^{n} h_k \change{t_k} \end{equation*}
of (oriented) rectangle areas is called the Riemann sum for \(s(t)\) over the domain \(t_0 \le t \le t_n\text{.}\)

Example 5.4.2. Riemann sum for the air pump.

Let’s unpack the notation of the definition above for the inflate-deflate-reinflate model from ExampleΒ 5.2.13. The step function in the model β€œsteps” output values at the following input values.
\begin{align*} t_0 \amp = 0 \amp t_2 \amp = 3 \amp t_4 \amp = 5 \amp t_6 \amp = 10 \\ t_1 \amp = 1 \amp t_3 \amp = 4 \amp t_5 \amp = 8 \end{align*}
The corresponding output height values between these stepping input values are:
\begin{align*} h_1 \amp = 0.5 \amp h_3 \amp = 0.25 \amp h_5 \amp = -0.2 \\ h_2 \amp = 0.75 \amp h_4 \amp = 0 \amp h_6 \amp = 0.5 \text{.} \end{align*}
Graph modelling inflating, partially deflating, and re-inflating an air raft.
The steps from the rate-versus-time graph of FigureΒ 5.2.14 are redrawn, this time without shading any rectangles. The horizontal positions where one step ends and the next begins have been labelled as \(t_0\) through \(t_6\text{,}\) with \(t_0\) at the origin and \(t_6\) at the closed endpoint on the horizontal axis as the beginning of the final step. The span along the horizontal axis between \(t_0\) and \(t_1\) has been labelled as \({\change{t}}_1\text{,}\) the span along the horizontal axis between \(t_1\) and \(t_2\) has been labelled as \({\change{t}}_2\text{,}\) and so on, until the final finite span along the horizontal axis between \(t_5\) and \(t_6\) has been labelled as \({\change{t}}_6\text{.}\) Finally, the heights of the six middle steps have been labelled \(h_1\) through \(h_6\text{.}\)
Figure 5.4.3. Riemann sum parameters for inflating and re-inflating an air raft.
The subdomain lengths are as follows.
\begin{align*} \change{t_1} \amp = t_1 - t_0 = 1 \\ \change{t_2} \amp = t_2 - t_1 = 2 \\ \change{t_3} \amp = t_3 - t_2 = 1 \\ \change{t_4} \amp = t_4 - t_3 = 1 \\ \change{t_5} \amp = t_5 - t_4 = 3 \\ \change{t_6} \amp = t_6 - t_5 = 2 \end{align*}
Then our Riemann sum is
\begin{align*} \sum_{k = 1}^{6} h_k \change{t_k} \amp = h_1 \change{t_1} + h_2 \change{t_2} + h_3 \change{t_3} + h_4 \change{t_4} + h_5 \change{t_5} + h_6 \change{t_6}\\ \amp = 0.5 \cdot 1 + 0.75 \cdot 2 + 0.25 \cdot 1 + 0 \cdot 1 + (-0.2) \cdot 3 + 0.5 \cdot 2\text{,} \end{align*}
just as in our previous calculation, and each term in the sum represents an oriented rectangle area, as pictured in FigureΒ 5.2.14 (though one of the rectangles has height \(0\) and can’t be seen in that diagram).

Example 5.4.5. Riemann sum for the air pump using a regular step function.

Let’s redo ExampleΒ 5.4.2 but interpreting the rate function as a regular step function.
Graph modelling inflating, partially deflating, and re-inflating an air raft.
The graph of FigureΒ 5.4.3 has been reproduced with some changes:
  • Each of the middle steps that were multiple minutes in duration has been split into multiple segments, all of duration one minute, by additional closed endpoints along the step.
  • The horizontal locations of the segment endpoints (new and old) have been relabelled \(t_0\) through \(t_{10}\text{,}\) so that now they are placed at one-minute intervals, with \(t_0\) at the origin and \(t_{10}\) at the closed endpoint on the horizontal axis as the beginning of the final step.
  • The spans between those labelled horizontal locations are all labelled simply as \(\change{t}\text{,}\) as they are all now of equal width.
  • The heights of the segments have been relabelled with \(h_1\) through \(h_{10}\text{,}\) so that each one-minute segment is assigned a separate label even if it is at the same height as the previous segment.
Figure 5.4.6. Regular Riemann sum parameters for inflating and re-inflating an air raft.
We have more subdomains this time, because we have split the longer subdomains up so that each subdomain has the same length.
Factoring out the common subdomain length, we have
\begin{align*} \sum_{k = 1}^{10} h_k \change{t} \amp = \left(\sum_{k = 1}^{10} h_k\right) \change{t}\\ \amp = (h_1 + h_2 + h_3 + h_4 + h_5 + h_6 + h_7 + h_8 + h_9 + h_{10}) \change{t}\\ \amp = (0.5 + 0.75 + 0.75 + 0.25 + 0 + (-0.2) + (-0.2) + (-0.2) + 0.5 + 0.5) \cdot 1\text{.} \end{align*}
This Riemann sum corresponds to the net (oriented) area of ten rectangles (though again one of the rectangles has height \(0\) and can’t be seen).
Graph modelling inflating, partially deflating, and re-inflating an air raft.
The graph of FigureΒ 5.4.6 is reproduced, but now with highlighted rectangles:
  • Each of the first four steps of the graph creates a rectangle with top side along the step and bottom side along the corresponding one-minute domain on horizontal axis. These rectangles have been shaded in blue and labelled \(R_1\) through \(R_4\text{.}\)
  • The rectangles similarly formed by the last two steps of the graph have also been shaded blue and are labelled \(R_9\) and \(R_{10}\text{.}\)
  • Each of the sixth through eighth steps of the graph creates a rectangle with bottom side along the step and top side along the corresponding one-minute domain on horizontal axis. These rectangles have been shaded in red and labelled \(R_6\) through \(R_8\text{.}\)
  • The fifth step of the graph lies along the horizontal axis, and so does not form a rectangle.
Figure 5.4.7. Inflating and re-inflating an air raft.

Remark 5.4.8.

It may seem that summing ten rectangle areas in ExampleΒ 5.4.5 is more work than summing six rectangle areas in ExampleΒ 5.4.2. But when programming a computer to do such sums, the regularly-spaced ten rectangles is easier to program then the irregularly-spaced six rectangles, and computers don’t care how many rectangle areas you ask them to sum (unless the number of rectangles is very, very large).