Skip to main content
Logo image

Section Piecewise Functions

Piecewise functions can feel disorganized at first since they are defined in separate β€œchunks” across different intervals. But there’s a powerful way to express them as a clean formula: by using step functions to switch each piece ON or OFF at the right time.

Subsection What Makes a Function Piecewise?

A piecewise function is any function built from different parts over specific regions of its domain. For example:
\begin{equation*} g(t)\ = \left\{ \begin{array}{ccccc} \DLBb \sin t, \amp \DLBb t \lt 0 \amp \\ \DLGa 2e^{-t}, \amp \DLGa 0 \ge t \lt 2 \amp \longrightarrow\\ \DLO 1.5, \amp \DLO t \ge 2 \amp \end{array} \right. \end{equation*}
Each piece has its own behavior, but together they create the entire function. The question is: can we rewrite these separate pieces so that the whole function is described with one equation, instead of a case-by-case breakdown?

Subsection Thinking in Terms of Switches

Checkpoint 256. πŸ“–β“ Match Step Functions to Their Piecewise Definitions.

    By dragging from left to right, match the function on the left to the equivalent piecewise function on the right. Note that, \(u_0(t) = u(t)\text{.}\)
  • \begin{equation*} \big( 1 - u_0(t) \big) \sin t \end{equation*}
  • \(\left\{\begin{array}{ll} \sin t \amp t \lt 0\\ 0 \amp \text{otherwise}\end{array}\right.\)
  • \begin{equation*} \big( u_0(t) - u_6(t) \big) \sin t \end{equation*}
  • \(\left\{\begin{array}{ll} \sin t \amp 0 \le t \lt 6\\ 0 \amp \text{otherwise}\end{array}\right.\)
  • \begin{equation*} u_0(t) \sin t \end{equation*}
  • \(\left\{\begin{array}{ll} \sin t \amp t \ge 0\\ 0 \amp \text{otherwise}\end{array}\right.\)
  • \begin{equation*} \big( u_0(t) - 1 \big) \sin t \end{equation*}
  • \(\big( u_6(t) - u_0(t) \big) \sin t \)
Every step function you’ve seen can be thought of as a simple ON–OFF switch:
\begin{equation*} \begin{array}{clllll} u_c(t) \amp\rightarrow\amp\text{ON:}\amp [c,\infty) \amp\text{OFF:}\amp\text{elsewhere}\\ u_c(t)-u_d(t) \amp\rightarrow\amp\text{ON:}\amp [c,d) \amp\text{OFF:}\amp\text{elsewhere}\\ 1 - u_c(t) \amp\rightarrow\amp\text{ON:}\amp (-\infty,c) \amp\text{OFF:}\amp\text{elsewhere} \end{array} \end{equation*}
With these step functions, you can literally β€œprogram” when each part of a function is ON and when it is OFF.
For example, the three pieces of \(g(t)\) above can be controlled like this:
\begin{equation*} \begin{array}{clllll} {\DLBb \sin t\ \big(1 - u_0(t)\big)} \amp\rightarrow\amp \sin t \amp\text{is ON:}\amp {\DLBb (-\infty,0)} \amp\text{OFF:}\amp\text{elsewhere}\\ {\DLGa 2e^{-t}\ \big(u_0(t) - u_2(t)\big)} \amp\rightarrow\amp 2e^{-t} \amp\text{is ON:}\amp {\DLGa [0,2)} \amp\text{OFF:}\amp\text{elsewhere}\\ {\DLO 1.5\ u_2(t)} \amp\rightarrow\amp 1.5 \amp\text{is ON:}\amp {\DLO [2,\infty)} \amp\text{OFF:}\amp\text{elsewhere} \end{array} \end{equation*}
(a) \({\DLBb \sin t\ \big(1 - u_0(t)\big)}\)
(b) \({\DLGa 2e^{-t}\ \big(u_0(t) - u_2(t)\big)}\)
(c) \({\DLO 1.5\ u_2(t)}\)
Figure 257. Three pieces of \(g(t)\)

Subsection Rewriting a Piecewise Function in Step Form

Checkpoint 258. πŸ“–β“ Matching Step Types to Intervals.

FigureΒ 257 shows three non-overlapping regions. That means for any value of \(t\text{,}\) only one piece of the function is active. Because of this, we can write \(g(t)\) as a single sum:
\begin{equation*} g(t) = \sin t\ \big( 1 - u_0(t) \big) + 2e^{-t}\ \big( u_0(t) - u_2(t) \big) + 1.5\ u_2(t)\text{.} \end{equation*}
Let’s test this step-function version by plugging in a few \(t\) values and seeing which terms turn ON and which turn OFF.
\begin{alignat*}{4} t=-2:\quad\amp g(-2) {}={} \amp\us{\large\text{ON}}{\ul{\sin(-2)\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{OFF}}{\ul{2e^{2}\cdot\big(0\big)}}\amp {}+{} \amp\us{\large\text{OFF}}{\ul{1.5\cdot\big(0\big)}} {}={} \amp \sin(-2)\\ t=0: \quad\amp \hphantom{-}g(1) {}={} \amp\us{\large\text{OFF}}{\ul{\sin(0)\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{ON}}{\ul{2e^{0}\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{OFF}}{\ul{1.5\cdot\big(1\big)}} {}={} \amp 2e^{0}\\ t=1: \quad\amp \hphantom{-}g(2) {}={} \amp\us{\large\text{OFF}}{\ul{\sin(1)\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{ON}}{\ul{2e^{-1}\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{OFF}}{\ul{1.5\cdot\big(1\big)}} {}={} \amp 2e^{-1}\\ t=4: \quad\amp \hphantom{-}g(4) {}={} \amp\us{\large\text{OFF}}{\ul{\sin(4)\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{OFF}}{\ul{2e^{-4}\cdot\big(1\big)}}\amp {}+{} \amp\us{\large\text{ON}}{\ul{1.5\cdot\big(1\big)}} {}={} \amp 1.5 \end{alignat*}
Like the piecewise form, plugging a specific \(t\) value into \(g(t)\) was the same as plugging it into just one of its three pieces. This observation highlights why the unit step form is equivalent to the piecewise form.

πŸ“œ Converting Piecewise Form to Unit Step Form.

Here’s a strategy for converting any piecewise function into step form:
  • Find the intervals where each piece is active.
  • Match the active interval for each piece to its step function switch:
    Piece Active Interval Step Function Switch
    \begin{equation*} P(t) \end{equation*}
    \begin{equation*} t \lt c \end{equation*}
    \begin{equation*} 1 - u_c(t) \end{equation*}
    \begin{equation*} Q(t) \end{equation*}
    \begin{equation*} c \le t \lt d \end{equation*}
    \begin{equation*} u_c(t) - u_d(t) \end{equation*}
    \begin{equation*} R(t) \end{equation*}
    \begin{equation*} t \ge d \end{equation*}
    \begin{equation*} u_d(t) \end{equation*}
  • Multiply the piece by its switch, then add them all together.

Checkpoint 259. πŸ“–β“ Which Term Matches the Interval?

You’re converting a piecewise function into step form. Which term below correctly captures a piece of the function that is active only for \(3 \le t \lt 6\text{?}\)
  • \(1 - u_3(t)\)
  • This turns ON before \(t = 3\) and OFF after. We want something that activates at \(t = 3\) and deactivates at \(t = 6\text{.}\)
  • \(1 - u_6(t)\)
  • This starts at \(t = 6\) and keeps going. It doesn’t define an interval, it defines a forever switch.
  • \(u_3(t) - u_6(t)\)
  • Exactly. This is the window function that’s ON from \(t = 3\) to \(t = 6\) and OFF otherwise.
  • \(u_6(t) - u_3(t)\)
  • Close, but this would result in \(-1\) on \(3 \le t \lt 6\text{,}\) not \(1\text{.}\) Try reversing the order of the terms.
Now you’re ready to try a few full conversions yourself.

🌌 Example 260. Using \(u_c(t)\) to Turn ON Sine.

Rewrite the function
\begin{equation*} g(t) = \left\{ \begin{array}{ll} \sin t, \amp t \ge \sfrac{\pi}{2} \\ 0, \amp \text{otherwise} \end{array} \right. \end{equation*}
using a unit step function.
Solution.
Since \(\sin t\) turns ON at \(t = \sfrac{\pi}{2}\text{,}\) we multiply it by \(u_{\sfrac{\pi}{2}}(t)\text{:}\)
\begin{equation*} g(t) = \sin t \cdot u_{\sfrac{\pi}{2}}(t) \end{equation*}
Plugging in \(u_{\sfrac{\pi}{2}}(t)\text{,}\) confirms we arrived at the correct piecewise function:
\begin{align*} g(t) = \sin t \cdot \ub{ \left\{ \begin{array}{ll} 1, \amp t \ge \sfrac{\pi}{2}\\ 0, \amp \text{otherwise} \end{array} \right. }_{\large u_{\sfrac{\pi}{2}}(t)} \quad \amp = \left\{ \begin{array}{ll} \sin(t) \cdot 1, \amp t \ge \sfrac{\pi}{2}\\ \sin(t) \cdot 0, \amp \text{otherwise} \end{array} \right.\\ \amp = \left\{ \begin{array}{ll} \sin(t), \amp t \ge \sfrac{\pi}{2}\\ 0, \amp \text{otherwise} \end{array} \right. \end{align*}
and has the following graph
Figure 261. Graph of \(\sin (t) \cdot u_{\sfrac{\pi}{2}}(t)\)

🌌 Example 262. Converting to Unit Step Form.

Rewrite the following piecewise functions using unit step notation:
\begin{equation*} P(t) = \left\{ \begin{array}{ll} e^{-t}, \amp t \lt 2.8 \\ 6 - t, \amp t \ge 2.8 \end{array} \right. \end{equation*}
\begin{equation*} Q(t) = \left\{ \begin{array}{ll} 2t, \amp 0 \le t \lt 1 \\ 3, \amp 1 \le t \lt 4 \\ 0, \amp t \ge 4 \end{array} \right. \end{equation*}
Solution 1. \(\rightarrow P(t)\)
The first piece is active before \(t = 2.8\text{,}\) so we use \(1 - u_{2.8}(t)\text{.}\) The second piece starts at \(t = 2.8\text{,}\) so we use \(u_{2.8}(t)\text{.}\) So:
\begin{equation*} P(t) = e^{-t} \cdot \left(1 - u_{2.8}(t)\right) + (6 - t) \cdot u_{2.8}(t) \end{equation*}
We can also combine terms with the same step:
\begin{align*} P(t) \amp = e^{-t} - e^{-t} \cdot u_{2.8}(t) + (6-t) \cdot u_{2.8}(t) \\ \amp = e^{-t} + \left(-e^{-t} + (6-t) \right) \cdot u_{2.8}(t) \text{.} \end{align*}
Solution 2. \(\rightarrow Q(t)\)
There are three pieces:
  • \(2t\) is ON from \(0 \le t \lt 1\) β†’ use \(u_0(t) - u_1(t)\)
  • \(3\) is ON from \(1 \le t \lt 4\) β†’ use \(u_1(t) - u_4(t)\)
  • \(0\) is ON for \(t \ge 4\) β†’ use \(u_4(t)\text{,}\) though it contributes nothing
Putting it together:
\begin{equation*} Q(t) = 2t \cdot \left(u_0(t) - u_1(t)\right) + 3 \cdot \left(u_1(t) - u_4(t)\right) \end{equation*}
Distribute and combine like unit step terms:
\begin{align*} Q(t) \amp = 2t \cdot u_{0}(t) - 2t \cdot u_{1}(t) + 3 \cdot u_{1}(t) - 3 \cdot u_{4}(t)\\ \amp = 2t\, u_0(t) + (3 - 2t)\, u_1(t) - 3\, u_4(t) \end{align*}
From here on out, we’ll use this compact step-function form whenever we need to handle piecewise forcing functions. This also unlocks the Laplace transform method for problems that contain piecewise forcing functions.

Subsection πŸ“€ Wrap-Up

πŸ—οΈ \(\textbf{Key Takeaways...}\)
  • Step functions are mathematical ON/OFF switches that let you control which piece is active.
  • By multiplying each piece by the right step expression, you can combine them into one neat formula.

Check Your Understanding.

Checkpoint 263. πŸ€”πŸ’­ Piecewise Functions Reading Questions.
(a) πŸ€”πŸ’­ Piecewise to Laplace.
You have attempted of activities on this page.