Piecewise Functions

A Function Can be in Pieces

You can create functions that behave differently depending on the input (x) value.

Piecewise Function

A function made up of 3 pieces

 

Example: A function with three pieces:

  • when x is less than 2, it gives x2,
  • when x is exactly 2 it gives 6
  • when x is more than 2 and less than or equal to 6 it gives the line 10-x

It looks like this:

Piecewise Function

(a solid dot means "including",
an open dot means "not including")

 

And this is how you write it:

Piecewise Function

The Domain is all Real Numbers up to and including 6:

Dom(f) = (-∞, 6] (using Interval Notation)

Dom(f) = {x member of Reals | x ≤ 6} (using Set Builder Notation)

And here are some example values:

X Y
-4 16
-2 4
0 0
1 1
2 6
3 7

 

Example: Here is another piecewise function:

  which looks like:  

 

The Absolute Value Function

The Absolute Value Function is a famous Piecewise Function.

It has two pieces:

  • below zero: -x
  • from 0 onwards: x

Absolute Value function

f(x) = |x|

Absolute Value function

The Floor Function

The Floor Function is a very special piecewise function. It has an infinite number of pieces:

Floor function

The Floor Function