---
# System prepended metadata

title: Piecewise functions
tags: ['2.1']

---

## Introduction to Piecewise Functions

A **piecewise function** is a function that is defined by different expressions depending on the value of $x$. When evaluating a piecewise function, there are three key steps:

1. **Identify the given** $x$.
2. **Determine which condition** or inequality applies to $x$.
3. **Plug $x$ into the corresponding expression** based on the condition.

### Step 1: Examples of $f(x)$

Start by plugging in simple values for $x$, but without evaluating yet. For example:

| Input | Interpretation |
|-------|----------------|
| $f(1)$ | $x = 1$ |
| $f(3)$ | $x = 3$ |
| $f(-2)$ | $x = -2$ |
| $f(5)$ | $x = 5$ |

---
### Step 2: Determine which inequality the input $x$ satisfies

For each $x$, you will show the inequalities and then check which one it fits.

---

#### Example 1: Evaluate $f(3)$

Let’s assume the piecewise function is defined as:

$$
f(x) = 
\begin{cases} 
x^2 + 1 & \text{if } x < 0 \\
2x - 3 & \text{if } 0 \leq x \leq 3 \\
x + 2 & \text{if } x > 3
\end{cases}
$$

| Condition            | Inequality | Satisfied? |
|----------------------|------------|------------|
| $x < 0$              | $3 < 0$    | False      |
| $0 \leq x \leq 3$    | $0 \leq 3 \leq 3$ | True |
| $x > 3$              | $3 > 3$    | False      |

Since $0 \leq 3 \leq 3$ is **True**, we use the second piece of the function: $2x - 3$.

---

#### Example 2: Evaluate $f(1)$

| Condition            | Inequality | Satisfied? |
|----------------------|------------|------------|
| $x < 0$              | $1 < 0$    | False      |
| $0 \leq x \leq 3$    | $0 \leq 1 \leq 3$ | True |
| $x > 3$              | $1 > 3$    | False      |

Since $0 \leq 1 \leq 3$ is **True**, we use the second piece again: $2x - 3$.


---

#### Example 3: Evaluate $f(-2)$

| Condition            | Inequality | Satisfied? |
|----------------------|------------|------------|
| $x < 0$              | $-2 < 0$   | True       |
| $0 \leq x \leq 3$    | $0 \leq -2 \leq 3$ | False |
| $x > 3$              | $-2 > 3$   | False      |

Since $-2 < 0$ is **True**, we use the first piece: $x^2 + 1$.



---

#### Example 4: Evaluate $f(5)$

| Condition            | Inequality | Satisfied? |
|----------------------|------------|------------|
| $x < 0$              | $5 < 0$    | False      |
| $0 \leq x \leq 3$    | $0 \leq 5 \leq 3$ | False |
| $x > 3$              | $5 > 3$    | True       |

Since $5 > 3$ is **True**, we use the third piece: $x + 2$.

---

### Step 3: Plug the $x$ value into the correct function piece

Now that you’ve determined which piece of the function to use, plug the $x$ value into that piece.

| Example        | Function to Use   | Calculation            | Result |
|----------------|-------------------|------------------------|--------|
| $f(3)$         | $2x - 3$          | $2(3) - 3 = 6 - 3$     | $3$    |
| $f(1)$         | $2x - 3$          | $2(1) - 3 = 2 - 3$     | $-1$   |
| $f(-2)$        | $x^2 + 1$         | $(-2)^2 + 1 = 4 + 1$   | $5$    |
| $f(5)$         | $x + 2$           | $5 + 2 = 7$            | $7$    |


## Exercises

### 1. $f(4)$

<details> <summary> Answer: </summary>

$f(4)=6$

</details>

### 2. $f(-1)$

<details> <summary> Answer: </summary>

$f(-1)=2$

</details>

### 3. $f(2)$

<details> <summary> Answer: </summary>

$f(2)=1$

</details>