matematicas visuales visual math
Constant Piecewise Functions: Step Functions


We are going to study a simple kind of functions. These are Piecewise constant functions or Step functions.

Although these functions are simple they are very important: we use them to approximate other more complex functions and they can help us to get an understanding of the Fundamental Theorem of Calculus from a basic point of view. For example, see Tom Apostol's book.

Some of the ideas and examples of this page are taken from two interesting articles by Gilbert Strang and Antony J. Macula.

A piecewise function is a function that is defined by several subfunctions. Each subfunction apply in a subdomain of the function's domain. In these pages, these subdomains will be intervals. We can say that these functions 'behave differently' based on the input value. For example, we use a different formula depending the input value.

If each piece is a constant function then the piecewise function is called Piecewise constant function or Step function.

For example, the following function has two parts:

Step functions: with two parts | matematicasVisuales

This is a typical notation we use for this function:

The graph of an step function is made by horizontal segments (or perhaps, rays)

Step functions: The graph of an step function is made by horizontal segments (or perhaps, rays) | matematicasVisuales

The Floor Function is an example of step function that has an infinite number of pieces.

Step functions: The Floor Function | matematicasVisuales

We remember that the function defined by f(x)=c, where c is a constant, a fixed number, is called a constant function. The graph of a constant function is a horizontal line.

A constant function is a special case of a linear or afine function. The derivative of a linear function is a basic example of derivative, it is a constant function.

Polynomial functions and derivative (1): Linear functions
The derivative of a lineal function is a constant function.

The definite integral of a constant function is the area of a rectangle (positive or negative).

Step functions: The definite integral of a constant function is the area of a rectangle (positive or negative) | matematicasVisuales
Step functions: The definite integral of a constant function is the area of a rectangle (positive or negative) | matematicasVisuales

The indefinite integral of a constant function is a linear function.

Step functions: The indefinite integral of a constant function is a linear function | matematicasVisuales
Step functions: The indefinite integral of a constant function is a linear function | matematicasVisuales
Polynomial functions and integral (1): Linear functions
It is easy to calculate the area under a straight line. This is the first example of integration that allows us to understand the idea and to introduce several basic concepts: integral as area, limits of integration, positive and negative areas.

Primitives of a constant function are linear functions.

Step functions: Primitives of a constant function are linear functions | matematicasVisuales

Slopes or these linear functions are the constant function.

Step functions: Slopes or these linear functions are the constant function | matematicasVisuales

Tom Apostol, in his book 'Calculus', began writing about the integral of a function defining the integral of steps functions.

To compute the integral of a step function

Step functions: To compute the integral of a step function | matematicasVisuales

we multiply each constant value by the length of the corresponding subinterval.

Then the value of the integral is the sum of the areas (positive or negative) of the individual rectangles. Notice that this value is independent of the values of the step function at the subdivision points. (Apostol, p. 65).

Step functions: To compute the integral of a step function | matematicasVisuales

(After that, Apostol prove several important properties of the integral, pags 68-69, and uses this definition to define the integral of more general functions, approximating a function from above and below by step functions. He wrote: "The approach will be patterned somewhat after the method of Archimedes. The idea is simply this: We begin by approximating the function f from below and from above by step functions." (p. 72))

We denote the indefinite integral as the function F(x):

Step functions: the indefinite integral as the function F(x) | matematicasVisuales

In those intervals where f is constant, the function F is linear. We describe this by saying that the integral of a step function is piecewise linear.(Apostol, p. 123)

Step functions: the integral of a step function is piecewise linear| matematicasVisuales

Observe also that the graph of f is made up of disconnected line segments. There are points on the graph of f where a small change in x produces a sudden jump in the value of the function. Note, however, that the corresponding indefinite integral does not exhibit this behavior. A small change in x produces only a small change in F(x). That is why the graph of F is not disconnected. This illustrates a general property of indefinite integrals known as continuity. (Apostol, p. 124).

As Spivak wrote, it appears that F is always better behaved than f.

It is interesting to understand the relation between these functions, F and f, that come in pairs. F is the integral of f and f is the derivative of F.

The use of graphs and the ideas of slope and area are tremendous visual supports. In Gilbert Strang's opinion the best approach is see f as velocity and F as distance.

We already know the first pair of functions: constant f and linear F. The second pair is what we are studying now: a piecewise constant f and a piecewise linear F.

Some examples from Gilbert Strang's article (you can try to reproduce these examples using the applet).

We can see the following graph as going forward and back (positive and negative constant velocity):

Step functions: going forward and back (positive and negative constant velocity) | matematicasVisuales

A steadily increasing velocity imitates f(x) = 2x

Step functions: A steadily increasing velocity imitates f(x) = 2x | matematicasVisuales

An oscillating velocity imitates f(x) = cos(x) and F(x) resembles roughly a sine curve:

Step functions: An oscillating velocity imitates f(x) = cos(x) and F(x) resembles roughly a sine curve | matematicasVisuales

An exponentially increasing velocity imitates f(x) = 2^x:

Step functions: An exponentially increasing velocity imitates f(x) = 2^x | matematicasVisuales

A burst of speed (then stop) makes F imitate a step function:

Step functions: A burst of speed (then stop) makes F imitate a step function | matematicasVisuales

We see that if f is a step function, F is a continuos piecewise linear function. But this function F is not a differentiable function. At some points it is not 'smooth'. The indefinite integral of a step function is piecewise differentiable.

Step functions: The indefinite integral of a step function is piecewise differentiable | matematicasVisuales

In this case we can say that the piecewise differentiable function F has lateral derivatives but they are not equal at some points:

Step functions: the piecewise differentiable function F has lateral derivatives but they are not equal at some points | matematicasVisuales
Step functions: the piecewise differentiable function F has lateral derivatives but they are not equal at some points | matematicasVisuales

The average value of a function f(x) over the interval [a,b] is given by

Step functions: average value of a function | matematicasVisuales

You can see the integral as an area or a distance.

One idea is that the area under the function (positive or negative) ...

Step functions: average value of a function | matematicasVisuales

... is the same as the area of a rectangle whose height is the average value.

Step functions: average value of a function | matematicasVisuales
Step functions: average value of a function | matematicasVisuales

First example (simple average):

Step functions: average value of a function | matematicasVisuales
Step functions: average value of a function | matematicasVisuales

Second example (weighted average):

Step functions: average value of a function (weighted average) | matematicasVisuales
Step functions: average value of a function (weighted average) | matematicasVisuales
Step functions: average value of a function (weighted average) | matematicasVisuales

Next we are going to study more about Continuous Linear Piecewise Functions and their relations with Step Functions and the Fundamental Theorem of Calculus.

REFERENCES

Tom M. Apostol, Calculus, Second Edition, John Willey and Sons, Inc.
Gilbert Strang, Sums and Differences vs. Integrals and Derivatives, The College Mathematics Journal, January 1990. JSTOR.
Anthony J. Macula, The Point-Slope Formula Leads to the Fundamental Theorem of Calculus, The College Mathematics Journal, Mathematical Association of America, 1995.
Michael Spivak, Calculus, Third Edition, Publish-or-Perish, Inc.

MORE LINKS

Non continuous Piecewise Linear Functions
Graphs of these functions are made of disconnected line segments. There are points where a small change in x produces a sudden jump in the value of the function.
Polynomial Functions (1): Linear functions
Two points determine a stright line. As a function we call it a linear function. We can see the slope of a line and how we can get the equation of a line through two points. We study also the x-intercept and the y-intercept of a linear equation.
Powers with natural exponents (and positive rational exponents)
Power with natural exponents are simple and important functions. Their inverse functions are power with rational exponents (a radical or a nth root)
Polynomial Functions (2): Quadratic functions
Polynomials of degree 2 are quadratic functions. Their graphs are parabolas. To find the x-intercepts we have to solve a quadratic equation. The vertex of a parabola is a maximum of minimum of the function.
Polynomial Functions (3): Cubic functions
Polynomials of degree 3 are cubic functions. A real cubic function always crosses the x-axis at least once.
Polynomial Functions (4): Lagrange interpolating polynomial
We can consider the polynomial function that passes through a series of points of the plane. This is an interpolation problem that is solved here using the Lagrange interpolating polynomial.
Polynomial functions and derivative (1): Linear functions
The derivative of a lineal function is a constant function.
Polynomial functions and derivative (2): Quadratic functions
The derivative of a quadratic function is a linear function, it is to say, a straight line.
Polynomial functions and derivative (3): Cubic functions
The derivative of a cubic function is a quadratic function, a parabola.
Polynomial functions and derivative (4): Lagrange polynomials (General polynomial functions)
Lagrange polynomials are polynomials that pases through n given points. We use Lagrange polynomials to explore a general polynomial function and its derivative.
Polynomial functions and derivative (5): Antidifferentiation
If the derivative of F(x) is f(x), then we say that an indefinite integral of f(x) with respect to x is F(x). We also say that F is an antiderivative or a primitive function of f.
Polynomial functions and integral (1): Linear functions
It is easy to calculate the area under a straight line. This is the first example of integration that allows us to understand the idea and to introduce several basic concepts: integral as area, limits of integration, positive and negative areas.
Polynomial functions and integral (2): Quadratic functions
To calculate the area under a parabola is more difficult than to calculate the area under a linear function. We show how to approximate this area using rectangles and that the integral function of a polynomial of degree 2 is a polynomial of degree 3.
Integral of powers with natural exponent
The integral of power functions was know by Cavalieri from n=1 to n=9. Fermat was able to solve this problem using geometric progressions.
Polynomial functions and integral (3): Lagrange polynomials (General polynomial functions)
We can see some basic concepts about integration applied to a general polynomial function. Integral functions of polynomial functions are polynomial functions with one degree more than the original function.
Definite integral
The integral concept is associate to the concept of area. We began considering the area limited by the graph of a function and the x-axis between two vertical lines.
Monotonic functions are integrable
Monotonic functions in a closed interval are integrable. In these cases we can bound the error we make when approximating the integral using rectangles.
Indefinite integral
If we consider the lower limit of integration a as fixed and if we can calculate the integral for different values of the upper limit of integration b then we can define a new function: an indefinite integral of f.
The Fundamental Theorem of Calculus (1)
The Fundamental Theorem of Calculus tell us that every continuous function has an antiderivative and shows how to construct one using the integral.
The Fundamental Theorem of Calculus (2)
The Second Fundamental Theorem of Calculus is a powerful tool for evaluating definite integral (if we know an antiderivative of the function).
Archimedes' Method to calculate the area of a parabolic segment
Archimedes show us in 'The Method' how to use the lever law to discover the area of a parabolic segment.