# Step By Step Calculus » 4.3 - Absolute Value and Piecewise-defined Functions

Synopsis
Piecewise-defined Function: Functions may be defined piecewise, that is, differently on different subsets of their domain, for example: f(x)= \left\{\begin{array}{ll}x-1,&x\leq0\\x+1,&x>0\end{array}\right.f(x)= \left\{\begin{array}{ll}x-1,&x\leq0\\x+1,&x>0\end{array}\right. is defined as x-1x-1 on interval (-\infty,0](-\infty,0] and x+1x+1 on interval (0,\infty)(0,\infty) while function f(x)= \left\{\begin{array}{ll}1,&x \in \mathbb{Q} \\ 0,& x \notin \mathbb{Q}\end{array}\right.f(x)= \left\{\begin{array}{ll}1,&x \in \mathbb{Q} \\ 0,& x \notin \mathbb{Q}\end{array}\right. is defined as 11 on the rationals and 00 on the irrationals.
This second example is quite different than the first since both the rationals and irrationals have holes and hence are not intervals. On the other hand, (-\infty,0]\cup(0,\infty)=\mathbb{R}=\mathbb{Q}\cup\mathbb{Q}'(-\infty,0]\cup(0,\infty)=\mathbb{R}=\mathbb{Q}\cup\mathbb{Q}' so the domain of both functions is \mathbb{R}\mathbb{R}.
Absolute Value Function: Recall that the absolute value of a number xx, denoted by |x||x|, is given by \displaystyle \left\{\begin{array}{ll} x & \textrm{ if } x\ge 0 \\-x &\textrm{ if } x\le 0\end{array}\right.\displaystyle \left\{\begin{array}{ll} x & \textrm{ if } x\ge 0 \\-x &\textrm{ if } x\le 0\end{array}\right.. This is a piecewise-defined function. The absolute value of an arbitrary function f(x)f(x), denoted by |f(x)||f(x)|, is
\displaystyle |f(x)|=\left\{\begin{array}{rl} -f(x), & \textrm{if }f(x)<0 \\ f(x), & \textrm{if } f(x)\ge 0\end{array}\right. .
\displaystyle |f(x)|=\left\{\begin{array}{rl} -f(x), & \textrm{if }f(x)<0 \\ f(x), & \textrm{if } f(x)\ge 0\end{array}\right. .
In order to sketch the graph of |f(x)||f(x)|, we first draw the graph of f(x)f(x) and then just reflect in the xx-axis the portions of the graph that are below xx-axis.