Piecewise Function: Definition, Evaluation & Examples

Piecewise Function: Definition, Evaluation & Examples

Edited By Komal Miglani | Updated on Oct 12, 2024 11:36 AM IST

In maths, a piecewise function is a function that is defined by different expressions for different intervals of the domain. These functions are useful for modeling and analyzing situations where a single formula cannot precisely describe the entire behavior of the function across its domain. Generally, the piecewise function is discontinuous in nature. They are used in real-world scenarios where a single rule does not apply to all domain values.

This Story also Contains
  1. What is a Piecewise Function?
  2. Domain and Range of Piecewise Function
  3. Continuous Piecewise Function
  4. Properties of Piecewise Functions
  5. Solved Examples Based On the Piecewise Functions
Piecewise Function: Definition, Evaluation & Examples
Piecewise Function: Definition, Evaluation & Examples

In this article, we will cover the concept of piecewise functions. This concept falls under the broader category of relations and functions. It is not only essential for board exams but also for competitive exams like the Joint Entrance Examination (JEE Main), and other entrance exams such as SRMJEE, BITSAT, WBJEE, BCECE, and more. Over the last ten years of the JEE Main exam (from 2013 to 2023), a total of six questions have been asked on this concept, including one in 2014, two in 2020, and three in 2021.

What is a Piecewise Function?

$A$ relation from a set $A$ to $a$ set $B$ is said to be a function from $A$ to $B$ if every element of set $A$ has one and only one image in set $B$.

A piecewise function is a type of function defined by different expressions for different intervals of the domain. Now, let us look in detail about what is a peicewise function.

Piecewise Function Definition

It is a function with more than one pieces of curves in its graph. It means that its output value changes according to different input values being inserted or other way round , a piecewise function behaves according to the input value and is dependend on it.

A piecewise function is a function $f(x)$ which has different definitions in different intervals of $x$. The graph of a piecewise function has different pieces corresponding to each of its definitions. For example, the absolute value function. We know that an absolute value function is $f(x)=|x|$ or $f(x)=\{x$, if $x \geq 0-x$, if $x<0 f(x)=\{x$, if $x \geq 0-x$, if $x<0$. We define it as:

  • $f(x)$ is equal to $x$ when $x$ is greater than or equal to 0 and
  • $f(x)$ is equal to $-x$ when $x$ is lesser than 0

Piecewise Function Examples

The examples of piecewise functions includes any function defined with more than one piece of curves in its graph. Some examples of piecewise function are $f(x)= \begin{cases}x+2 & \text { if } x<0 \\ x^2 & \text { if } x \geq 0\end{cases}$, $f(x)= \begin{cases}x & \text { if } x \geq 0 \\ -x & \text { if } x<0\end{cases}$, $f(x)= \begin{cases}1 & \text { if } 0 \leq x<1, \\ 2 & \text { if } 1 \leq x<2, \\ 3 & \text { if } 2 \leq x<3\end{cases}$, $f(x)= \begin{cases}5 & \text { if } x<-2, \\ 0 & \text { if }-2 \leq x \leq 2, \\ -5 & \text { if } x>2\end{cases}$ etc. as each of these include the functions defined with different curves.

Piecewise Function Graph

The graph of piecewise functions represents the different curves of the piecewise function give.

Example: Graph the piecewise defined function $
f(x) =
\begin{cases}
-2x & \text{if } x < -2 \\
-|x| & \text{if } -2 \leq x \leq 0 \\
2 - x^2 & \text{if } x > 0
\end{cases}
$.

Solution:

$f(x)$ has $ 3$ definitions:

  • $-2^{\mathrm{x}}$ when x is less than -2 and this is an exponential function.
  • |x| when -2 is less than or equal to $x$ less than or equal to 0 and this is an absolute value function.
  • $2-x^2$ when $x$ is greater than 0 and this is a quadratic function.
JEE Main Highest Scoring Chapters & Topics
Just Study 40% Syllabus and Score upto 100%
Download E-book

Let us write the intervals and their corresponding definitions. Also, let us frame tables that include the endpoints of the intervals and also several other random numbers from each interval. We will calculate the value of y in each case using the corresponding definition.

piecewise function table

Now, we plot these points on the graph. Note that we have to put open dots at $(-2, -0.25)$ (first table) and $(0, 2)$ (last table) as their corresponding x coordinates are excluded from the interval.

piecewise function graph

We note that the left most (light orange colored) curve is extended to the left side as it corresponds to the interval $x<-2$. Also, the right-most (blue-colored) curve is extended in the interval $x>0$. The middle (dark orange colored) curve is NOT extended on either side as it belongs to the interval $-2 \leq x \leq 0$.

Domain and Range of Piecewise Function

It is enough to look at the definition of function to find out the domain and range of the function. For doing so, we take the union of all intervals with $x$ and that will give us the domain. In the above example, the domain of $f(x)$ is, $\{x \mid x<-2\} \cup\{x \mid-2 \leq x \leq 0\} \cup\{x \mid x>$ $0\}$. The union of all these sets is just the set of all reals. So the domain of $f(x)$ (in the above example) is $R$.

The range of the function can be simply found out by graphing the function and looking at the $y$ axis. In the above example, all $y$-values less than 2 (exclude 2 as there is an open dot at $(0,2)$ ) are covered by the graph. So its range is $\{y \mid y<2\}$ (or) $(-\infty, 2)$.

Continuous Piecewise Function

It simply reflects the continuous nature of the function and means that the graph can be drawn by without lifting the pencil even once. This is the simplest and most convenient way to check the continuity of any kind of function.

$f(x) =
\begin{cases}
x - 1 & \text{if } x < -2 \\
-3 & \text{if } x \geq -2
\end{cases}
$

piecewise continuous function

Properties of Piecewise Functions

The properties of piecewise functions are,

  • A continuous piecewise function has no breaks or jumps in its graph.
  • Some piecewise functions may not be differentiable at the points where the sub-functions meet.
  • Functions in a piecewise function can be linear, quadratic, or any other algebraic form, contributing to the study of algebra piecewise functions.

Important Notes on Piecewise Functions

  • If we wish to evaluate the piecewise function at the input stage, we see which interval it belongs to and substitute it in the given definition of the function. Then we plot the graph of the function, we uuse open dots at the points whose x-coordinates are not included in the corresponding intervals. An open dot at a point means that a particular point is NOT a part of the function.
  • The domain of the function is simply obtained by taking the union of all individual piecewise functions.
  • To find the range, we just graph it and look for the y-values that are covered by the graph.

Recommended Video Based on Piecewise Functions


Solved Examples Based On the Piecewise Functions

Example 1: What is the range of $f(x)=4[x]$ ?
Solution:
Range of $[x]$ is Z i.e $\{\ldots-2,-1,0,1,2 \ldots\}$
so Range of $4[x]$ is $\{\ldots-8,-4,0,4,8\}$
Example 2: What is the range of function $f(x)=\{x\}+\{-x\}$
1) $[0,1)$
2) $(-1,1)$
3) $\{0,1\}$
4) $[0,1]$

Solution:

$
f(x)=\{x\}+\{-x\}
$

If $x \in Z$, then $f(x)=0$
If $x$ is not an integer, then let $x=Z+k$

$
\begin{aligned}
& f(x)=\{Z+k\}+\{-Z-k\} \\
& =k+1-k=1
\end{aligned}
$
Hence, the answer is the option 3.

Example 3: Let [t] denote the greatest integer. Then the equation in $\mathrm{x},[x]^2+2[x+2]-7=0$ has.
1) exactly two solutions
2) exactly four integral solution
3) no integral solution
4) infinitely many solutions

Solution:

$\begin{aligned}
& {[\mathrm{x}]^2+2[\mathrm{x}+2]-7=0} \\
& \Rightarrow[\mathrm{x}]^2+2[\mathrm{x}]+4-7=0 \\
& \Rightarrow[\mathrm{x}]=1,-3 \\
& \Rightarrow \mathrm{x} \in[1,2) \cup[-3,-2)
\end{aligned}$
Hence, the answer is option (4).

Example 4: The real-valued function $f(x)=\frac{\operatorname{cosec}^{-1} x}{\sqrt{x-[x]}}$, where $[x]$ denotes the greatest integer less than or equal to x , is defined for all $x$ belonging to :
1) all non-integers except the interval $[-1,1]$
2) all real except integers
3) all integers except $0,-1,1$
4) all real except the interval $[-1,1]$

Solution:

$f(x)=\frac{\operatorname{cosec}^{-1} x}{\sqrt{\{x\}}}$

Domain of $\operatorname{cosec}^{-1} x$ is $|x| \geq 1$

and $x-[x]>0 \Rightarrow x \in R-\{I\}$

So $x \in R-I-[-1,1]$

Hence, the answer is the option 1.

Example 5: If $f(x)=3 \operatorname{sgn}(x)$. Then what is the range of $\mathrm{f}(\mathrm{x})$ ?

1) $\{-1,0,1\}$

2) $\{\frac{-1}{3},0,\frac{1}{3}\}$

3) $\{-3,0,3\}$

4) $\{-1,1\}$

Solution:

As $\operatorname{sgn}(x)$ can take only three values $-1,0$ and 1
So $3 \operatorname{sgn}(x)$ can take only three values $-3,0,3$
So, the range of this function is $\{-3,0,3\}$
Hence, the answer is the option 3.

List of Topics Related to Piecewise Function


Frequently Asked Questions (FAQs)

1. What is piecewise function in math?

A piecewise function is a function that is built from pieces of different functions over different intervals. For example, we can make a piecewise function $f(x)$ where $f(x)=-9$ when $-9<x \leq-5, f(x)=6$ when $-5<x \leq-1$, and $f(x)=-7$ when $-1$.

2. What is an easy piecewise function example?

An example of a piecewise function is the absolute value function. The absolute value function can be written as $f(x)=| x |$. This function has three different pieces, $x$ for all values less than $1, x^2$ for all values between 1 and 3 (including 1 and 3 ) and finally, $x+3$ for all values greater than three.

3. What is another name for a piecewise function?

In mathematics, a piecewise function (also called a piecewise-defined function, a hybrid function, or a function defined by cases) is a function whose domain is partitioned into several intervals ("subdomains") on which the function may be defined differently.

4. What are the examples of piecewise functions?

Some examples include linear, quadratic, cubic, rational, square root, absolute value, exponential, logarithmic, trigonometric, inverse trigonometric, etc.

5. What is a piecewise step function?

In Mathematics, a step function (also called as staircase function) is defined as a piecewise constant function, that has only a finite number of pieces. In other words, a function on the real numbers can be described as a finite linear combination of indicator functions of given intervals.

Articles

Get answers from students and experts
Back to top