 # PIECEWISE FUNCTION: How to Graph Piecewise Defined Functions? Brief Introduction, Examples and Uses:-

## Introduction

Certain functions are defined differently on different parts of their domain and are thus more naturally expressed in terms of more than one formula. We refer to such function as piecewise function or piecewise-defined function. Piecewise functions will be useful to us in the study of limits, continuity, and the derivative as examples and counterexamples of functions having certain properties.

If you don’t find enough time to complete this article in a single read, make sure to BOOKMARK this page for future saturation if you don’t want to miss this useful content.

## Examples: How to Graph Piecewise-Defined Function?

Example#1

Let f be the function defined by;

$f(x) = \begin{cases} x-1, \text{ if } x <3 \\ 5, \text{ if } x =3 \\ 2x+1 , \text{ if } 3 < x \end{cases}$

Determine the domain and range of f, and sketch its graph.

Solution:-

The domain of f is (-∞, +∞), the following figure shows the graph of ‘f’;

it consists of the portion of the line y=x-1 for which x<3, the point (3,5), and the portion of the line y = 2x+1 for which 3<x. The function values are either numbers less than 2, the number 5, or the numbers greater than 7. Therefore the range of f is the number 5 and the numbers (-∞, 2) ∪ (7, +∞).

Example#2

Let g be the function defined by;

$f(x) = \begin{cases} 3x-2, \text{ if } x < 1 \\ x^2, \text{ if } 1 ≤ x \end{cases}$

Determine the domain and range of g, and sketch its piecewise graph.

Solution:-

The domain of g is (-∞, +∞), following is the graph of the function;

The graph contains the portion of the line y= 3x-2 for which x<1 and the portion of the parabola y = x2 for which 1 ≤ x. The range is (-∞, +∞).

Example#3

The H be the function defined by;

$H(x) = \begin{cases} x+3, \text{ if } x ≠ 3 \\ 2 , \text{ if } x = 3 \end{cases}$

Determine the domain and range of H and sketch its graph.

Solution:-

As H is defined for all x, its domain is (-∞, +∞), the graph is sketched below;

The range is the set of all real numbers except 6, so in terms of set, we can express range as ℝ-{6}.

Example#4

The piecewise function f is defined by;

$f(x) = \begin{cases} x^2, \text{ if } x ≠ 2 \\ 7 , \text{ if } x = 2 \end{cases}$

Determine the domain and range of f and sketch its graph.

Solution:-

Because f is defined for all x, the domain is (-∞, +∞). The graph appearing below;

consists of the point (2, 7) and all the points on the parabola y = x2 except (2, 4). The range is [0, +∞).

Example#5

Determine the domain and range of the absolute value function ‘f’ for which f(x) = |x| and sketch its graph.

Solution:-

From the definition of absolute value function |x|, f(x) is defined piecewise as below,

$f(x) = \begin{cases} x, \text{ if } x ≥ 0 \\ -x , \text{ if } x < 0 \end{cases}$

The domain is (-∞, +∞). The graph of ‘f’ consists of two half-lines through the origin and above the x-axis.

one has slope 1 and the other has slope -1. The range is [0, +∞).

Example#6

The piecewise function f is defined by;

$f(x) = \begin{cases} -2, \text{ if } x ≤ 3 \\ 2 , \text{ if } 3 < x \end{cases}$

Determine the domain and range of ‘f’ and sketch its graph.

Solution:-

The domain of g is (-∞, +∞), following is the graph of the function;

Example#7

A piecewise function f is defined by;

$f(x) = \begin{cases} 1 – x^2 , \text{ if } x < 0 \\ 3x + 1 , \text{ if } 0 ≤ x \end{cases}$

Determine the domain and range of ‘f’ and sketch its graph.

Solution:-

The domain of g is (-∞, +∞), following is the graph of the function;

This is a continuous graph having a range (-∞, +∞).

Example#8

A piecewise function f is defined by;

$f(x) = \begin{cases} 6x + 7 , \text{ if } x ≤ -2 \\ 4 – x , \text{ if } -2 < x \end{cases}$

Determine the domain and range of ‘f’ and sketch its graph.

Solution:-

The domain of g is (-∞, +∞), following is the graph of the function;

The range is (-∞, 6).

Example#9

Sketch the graph of the signum function (or sign function), denoted by “sgn” and defined piecewise as below;

$sgn(x) = \begin{cases} -1 , \text{ if } x < 0 \\ 0 , \text{ if } x = 0 \\ 1 , \text{ if } 0 < x \end{cases}$

sgn x is read “signum of ‘x'”.

Solution:-

The domain of sgn x is (-∞, +∞). Following is the graph of sign (signum) function;

The range comprises mere three integers as mentioned in the question i.e. {-1, 0, 1}.

Example#10

Sketch the graph and determine the domain and range of the following piecewise function h(x):

$h(x) = \begin{cases} x+3 , \text{ if } x < -5 \\ \sqrt{25-x^2} , \text{ if } -5 ≤ x≤ 5 \\ 3-x , \text{ if } 5<x \end{cases}$

Solution:-

The domain is (-∞, +∞), following is how we have sketched the graph;

And the range is (-∞, -2) ∪ [0, 5].

## How to use piecewise function calculator to sketch its graph?

There are various online and downloadable graphing calculators available that facilitate users to sketch piecewise functions, few are as under;

### Learn how to use Desmos Graphing Calculator to sketch a piecewise function

Here I am going to elaborate on how to sketch piecewise functions graph using Desmos graphing calculator?

In the above video, I have selected a few of the examples that were solved and sketched manually in this article, and input their piecewise definitions with corresponding domains in order to obtain their graph, I have picked Example#1 here and tried to substitute commands on Desmos interface, let’s try to understand step by step.

STEP#1

• Open Desmos graphing calculator
• Type first piecewise domain and then the particular function seperated by “:”
• Enclose this command in { } brackets.

STEP#2

As ‘3’ is not included in the first piecewise domain “x<3” this means that the subjective graph does not contain (3, 2), so we have to develop a “hole” there, for this purpose;

• Click on “+” icon at the top right, this will open next expression tab.
• Type (3, 2)
• Press on the colorful circle next to (3,2), you’ll get a panel from where you can select the hollow circle option.
• Click on the hollow-point icon.

First piecewise is now accomplished.

STEP#3

• Plot the point (3, 5), that was the second definition of given piecewise function.
• Keep it a solid point.

STEP#4

• Finally type y= {3<x : 2x+1}
• We will get another straight line representing the graph of f(x) = 2x+1 within the domain containing all values of x>3.
• As “3” is not included in the domain of f(x)= 2x+1, so we are not going to include (3, 7).
• Type (3,7) as another expression and make it a “hole”.

STEP#5

• Lets apply aforementioned strategies in Example#10

For more examples, you can watch my aforementioned video.

## Uses/Applications of piecewise functions

Piecewise functions in addition to Calculus magnanimously contribute in mathematical modeling of various day-to-day real-life problems, which are later evaluated to get optimal and exact solutions. I have tried to compile some examples from the fields of Accounts, Physics, Biology, etc, which would help you to get an idea about the applications and significance of piecewise functions.

• In Denmark, income tax is assigned on the basis of income value, here f(x) is function that represents the percentage of income that is deducted as tax and ‘x’ defines the income value.
$f(x) = \begin{cases} 0, \text{ if } x < 10,000 \\ 10\text{%} , \text{ if } 10,000 ≤ x≤ 20,000 \\ 15\text{%} , \text{ if } x> 20,000 \end{cases}$
$C(x) = \begin{cases} 7x, \text{ if } 0<x \le 10 \\ 5x , \text{ if } 11 ≤ x≤ 50 \\ 3x , \text{ if } x> 50 \end{cases}$

Where C(x) is the total cost of caps, and ‘x’ is the number of caps so-ordered.

• Most of the time there is just one copy of each gene in the early stage of growth of a eukaryotic cell, which is represented as Ni-1. Whereas, in bacterias, there are multiple DNA plasmids in each cell (more than 100). Now for the sake of simplicity, it is assumed that before cell division genes or DNAs including plasmid DNA are duplicated. Here we have symbolized the cycle period of cell division as “𝜏”, thus, the following piecewise function can be used to explain cell volume factor v(t).
$v(t) = \begin{cases} e^{\left( t/\tau-k\right) \ln 2} , \text{ if } k𝜏 ≤ t < (k+1)𝜏 \\ 1, \text{ if } t = (k+1)𝜏 \end{cases}$
• A heavy duty vehicle is moving on highway with a variable velocity defined piecewisely below;
$v(t) = \begin{cases} 5t, \text{ if } 0 \le t < 15 \\ 70 , \text{ if } 15 ≤ x< 50 \\ 250-3t , \text{ if } t \geq 50 \end{cases}$

## Conclusion

Piecewise function is indeed a hallmark in the field of Calculus and is deeply involved in the concepts of limits, continuity, differential and integral calculus. Beyond doubt, piecewise functions have simplified many complex targets of

• Virtual strain fields
• Artificial intelligence
• Random field modelling
• Optical Science
• Pharmaceutical sciences (Pharmacokinetics)
• Laser scanning for environmental sciences
• Scientific computation in Electrical Engineering
• Sorting out issues in Geology and Mineralogy
• Business, social and life sciences

Everything, that we study in mathematics has its profound significance and substantial contribution in multifarious fields of real life, piecewise function is a clear example of this.

Related Articles:

Epsilon And Delta Definition Of Limit

Continuous Vs Discontinuous Functions

Squeeze Theorem & Continuity of Trigonometric Functions