Piecewise defined functions are used in many real-world phenomena (e.g. postal rates and income tax formulas) are modeled by such functions. It is important that we are familiar with them and know how to evaluate them. Consider the absolute value function \(f(x)=\left|x\right|\). The domain is real numbers and the range is values greater than or equal to 0. If we input 0 or any positive value, the output is the same value as the input (\(f(0)=\left|0\right|=0\), \(f(3)=\left|3\right|=3\), \(f(7.2)=\left|7.2\right|=7.2\), . ). \(f(x) = x\) if \(x \ge 0\) If we input a negative value the sign of the output must change from negative to positive (\(f(-1)=\left|-1\right|=1\), \(f(-4.5)=\left|-4.5\right|=4.5\), . ). \(f(x) = -x\) if \(x < 0\), since multiplying a negative value by -1 makes it positive. Since this requires two different processes or pieces, the absolute value function is often called the most basic piecewise defined function.
A piecewise function is a function in which the formula used depends upon the domain the input lies in. We notate this idea like: \[f(x) = \begin \text \\ \text \\ \text \end\nonumber \] Note that piecewise defined functions are not rescricted to 3 formulas, they may contain 2 or more.
A museum charges $5 per person for a guided tour with a group of 1 to 9 people, or a fixed $50 fee for 10 or more people in the group. Set up a function relating the number of people, \(n\), to the cost, \(C\). Solution To set up this function, two different formulas would be needed. C = 5n would work for n values under 10, and C = 50 would work for values of n ten or greater. Notating this: \[C(n) = \begin 5n & \text \\ 50 &\text n \ge 10\end\nonumber \]
Solution
A cell phone company uses the function below to determine the cost, C, in dollars for g gigabytes of data transfer.
Find the cost of using 1.5 gigabytes of data, and the cost of using 4 gigabytes of data.
Solution
To find the cost of using 1.5 gigabytes of data, \(C(1.5)\), we first look to see which piece of domain our input falls in. Since 1.5 is less than 2, we use the first formula, giving \(C(1.5)\) = $25.
The find the cost of using 4 gigabytes of data, \(C(4)\), we see that our input of 4 is greater than 2, so we’ll use the second formula. \(C(4)\) = 25 + 10(4 - 2) = $45.
The height \(h\) in feet of a model rocket above the ground \(t\) seconds after lift-off is given by
\[ h(t) = \left\< \begin -5t^2 + 100t, & \mbox & 0 \leq t \leq 20 \\ 0, & \mbox & t > 20 \\ \end \right.\nonumber\]
Solution
Previously, we learned how to evaluate piecewise defined functions. Next, let's focus on how to graph them.
Given a piecewise function, sketch a graph.
Note: It is important to not just plot some points when graphing piecewise functions.
Sketch a graph of the following piecewise-defined function:
Solution
Graph the linear function \(y=x+3\) on the interval \((−∞,1)\) and graph the quadratic function \(y=(x−2)^2\) on the interval \([1,∞)\). Since the value of the function at \(x=1\) is given by the formula \(f(x)=(x−2)^2\), we see that \(f(1)=1\). To indicate this on the graph, we draw a closed circle at the point \((1,1)\). The value of the function is given by \(f(x)=x+3\) for all \(x
7 to 5 and the y axis runs from -4 to 6. The graph is of a function that has two pieces. The first piece is an increasing line that ends at the open circle point (1, 4) and has the label “f(x) = x + 3, for x < 1”. The second piece is parabolic and begins at the closed circle point (1, 1). After the point (1, 1), the piece begins to decrease until the point (2, 0) then begins to increase. This piece has the label “f(x) = (x - 2) squared, for x >
= 1”.The function has x intercepts at (-3, 0) and (2, 0) and a y intercept at (0, 3)." />
2) Sketch a graph of the function
In a big city, drivers are charged variable rates for parking in a parking garage. They are charged $10 for the first hour or any part of the first hour and an additional $2 for each hour or part thereof up to a maximum of $30 for the day. The parking garage is open from 6 a.m. to 12 midnight.
Solution
1.Since the parking garage is open 18 hours each day, the domain for this function is \(\\). The cost to park a car at this parking garage can be described piecewise by the function
2.The graph of the function consists of several horizontal line segments.
The cost of mailing a letter is a function of the weight of the letter. Suppose the cost of mailing a letter is \(49¢\) for the first ounce and \(21¢\) for each additional ounce. Write a piecewise-defined function describing the cost \(C\) as a function of the weight \(x\) for \(0
Hint
The piecewise-defined function is constant on the intervals \((0,1],\,(1,2],\,….\)
Answer
Sketch a graph of the function.
Solution
Each of the component functions is from our library of toolkit functions, so we know their shapes. We can imagine graphing each function and then limiting the graph to the piece we need for the indicated domain of the piecewise function we are graphing. At the endpoints of the domain interval, draw open circles to indicate where the endpoint is not included because of a less-than or greater-than inequality; we draw a closed circle where the endpoint is included because of a less-than-or-equal-to or greater-than-or-equal-to inequality.
Figure \(\PageIndex\) shows the three components of the piecewise function graphed on separate coordinate systems.
Figure \(\PageIndex\): Graph of each part of the piece-wise function f(x)
Now that we have sketched each piece individually, we then combine them in the same coordinate plane to form the graph of the piecewise function. See Figure \(\PageIndex\).
Analysis
Note that the graph does pass the vertical line test even at \(x=1\) and \(x=2\) because the points \((1,3)\) and \((2,2)\) are not part of the graph of the function, though \((1,1)\) and \((2, 3)\) are.
Graph the following piecewise function.
Answer
This page titled Page 2.7: Piecewise Defined Functions is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Chau D Tran via source content that was edited to the style and standards of the LibreTexts platform.