# Piecewise Functions

**Piecewise functions** are functions that have multiple pieces, or sections. They are defined piece by piece, with various functions defining each interval.

## Introduction

Piecewise functions can be split into as many pieces as necessary. Each piece behaves differently based on the input function for that interval. Pieces may be single points, lines, or curves. The piecewise function below has three pieces. The piece on the interval $-4\leq x \leq -1$ represents the function $f(x)=3x+5.$ The piece on the interval $-1 \leq x < 3$ represents the function $f(x)=2.$ The piece on the interval $3 \leq x \leq 4$ represents the function $f(x)=-x+2.$

Using function notation, we represent the graph as: $f(x) = \begin{cases} 3x+5 & -4 \leq x \leq -1 \\ 2 & -1 \leq x < 3 \\ -x + 2 & 3 \leq x \leq 4 \end{cases}.$

## A certain cab company has a $2.00 base charge, and then charges $0.50 per minute. There is also a $7.00 minimum fee (so if the base charge and minutes combined don't add to $7, the rider is charged a flat amount of $7).

Which function describes riding a cab from the company for $x$ minutes and spending $f(x)$ dollars?

A.$f(x) = \begin{cases} 7 & 0 < x \leq 7 \\ 2 + 0.50x & x > 7 \end{cases}$

B.$f(x) = \begin{cases} 7 & 0 < x \leq 10 \\ 2 + 0.50x & x > 10 \end{cases}$

C.$f(x) = \begin{cases} 7 & 0 < x \leq 14 \\ 2 + 0.50x & x > 14 \end{cases}$

Remember that $x$ is the number of minutes, but the cutoff for the minimum fare is based on dollars. So we need to figure out how many minutes will reach $7. That would be when $2 + 0.50x = 7,$ so $0.50x = 5$ or $x= 10 .$ This means we want the piecewise function to be split starting at 10 minutes, when the minimum fare threshold is passed.

## One of the most common piecewise functions is the absolute value function. How can we write $f(x)=|x|$ as a piecewise function?

$f(x)=|x|$ is the combination of two linear functions: $f(x) = \begin{cases} -x & x<0 \\ x & x\geq 0 \end{cases}.$

## Evaluating Piecewise Functions

When evaluating a piecewise function, we need to determine which piece of the function to use. Let's find $f(-2)$ if $f(x) = \begin{cases} 3x+5 & -4 \leq x \leq -1 \\ 2 & -1 \leq x < 3 \\ -x + 2 & 3 \leq x \leq 4 \end{cases}.$

$f(-2)$ indicates that we want to determine the value of the function when $x=-2.$ An $x$-value of $-2$ falls into the first piece of the function, where $f(x)=3x+5$ for $-4 \leq x \leq -1.$ Therefore, $f(-2)=3(-2)+5 = -1.$

## Find $f(3)$ if

$f(x) = \begin{cases} 3x-2 & -5 \leq x < 2 \\ x^2+1 & 2 \leq x < 4 \\ -3x+1 & x\geq4 \end{cases}.$

f\(3 falls into the piece of the graph where $f(x)=x^2+1$ for $2\leq x < 4.$ Therefore, $f(3)=3^2+1 = 10.$

## If piecewise function $f$ given below is continuous, then what is the value of $Q?$ (In the context of this problem, "continuous" means the endpoints of the graph portions meet at $x=2$ so there is no "gap".)

$f(x) = \begin{cases} -3x+2 & x \leq 2 \\ x^2 - Q & x > 2 \end{cases}$

At $x = 2 ,$ the graph $y = -3x + 2$ is at the point $(2, -4) .$

When $Q = 0$ and $x = 2 ,$ the graph $y = x^2 - Q$ is at the point $(2, 4) .$

So we need to shift the parabola graph down by $4 + 4 = 8$ so the points match. This indicates $Q = 8 .$

## Graphing Piecewise Functions

To graph a piecewise function, we graph the different pieces for the different sub-intervals. Let's graph $f(x) = \begin{cases} 2x+1 & x \leq -1 \\ x^2 & -1 < x \leq 2 \\ 4 & x > 2 \end{cases}.$

This piecewise graph has three pieces and two boundary points at $x=-1$ and $x=2.$ The first piece of our graph is the linear function$f(x)=2x+1$ for $x\leq -1.$ $f(-1)=2(-1)+1 = -1$ so we'll have a filled in dot at $(-1,-1)$ with a slope of 2 traveling from the point toward negative infinity.

Next, we have the quadratic function $f(x)=x^2$ for $-1<x<2$ with boundary points of $-1$ and $2.$ $f(-1)=(-1)^2=1$ so we'll have an open dot at $(-1,1)$ and $f(2)=2^2=4$ so we'll have a closed dot at $(2,4)$.

The third piece is the horizontal linear function of $f(x)=4$ from $x=2$ to infinity.

## What is the correct graph of

$f(x) = \begin{cases} -2x+1 & x \leq 2 \\ \frac{1}{2}x-4 & x >2 \end{cases}?$

Graph A has the correct functions but the wrong boundary point of $x=0$ instead of $x=2.$ Graph C has the correction functions and the correct boundary point, but the dot should be a closed dot because the first function includes the value $x=2.$ Therefore, Graph B is correct.

**Cite as:**Piecewise Functions.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/piecewise-functions/