Writing a piecewise function for $f(x) = \mid x+3\mid -\mid x-1\mid $ 
I am wanting to write a piecewise function for the following:
$$f(x)= \mid x+3\mid -\mid x-1\mid $$

I know how to write piecewise functions for functions that have a single set of absolute value brackets, but I don't know how to deal with two sets of brackets. A hint would be appreciated.
 A: Deal with three separate cases :


*

*When $x+3\geqslant0$ and $x-1\geqslant0$.

*When $x+3\lt0$ and $x-1\geqslant0$.

*When $x+3\geqslant0$ and $x-1\lt0$.

*When $x+3\lt0$ and $x-1\lt0$.


Alternatively you can use a table to see the signs that are being taken by each expression inside the absolute values :
$$
\begin{array}{|c|lcccr|}\hline
x & -\infty  & -3 & & 1  &  \infty \\ \hline
x-1 &\qquad \color{green}{-} & \big| & \color{green}- & 0 & \color{red}+\qquad     \\ \hline
x+3 & \qquad\color{green}- & 0 & \color{red}+ & \big| & \color{red}+\qquad   \\ \hline
-|x-1| & \,\,\,\,\,\,\,x-1 & \big| & x-1 & \big| & -x+1\quad  \\ \hline
|x+3| & \,\,\,-x-3 & \big| & x+3 & \big| & x+3\quad  \\ \hline
\end{array}
$$
From the table, if $x\in(-\infty,-3\,]$ then $f(x)=(x-1)+(-x-3)=\ldots$ if $x\in[-3,1]$ then $f(x)=(x-1)+(x+3)=\ldots$ if $x\in[1,\infty)$ then $f(x)=(-x+1)+(x+3)=\ldots$ I guess you can continue from here.
A: The idea is the following:
The absolute value of $y$ is given by
$$|y| = \begin{cases} y&\text{if } y\geq 0\\-y&\text{if } y<0\end{cases}$$
The point is now to check when $x+3$ and $x-1$ are positive, and when they are negative.
Let us look at the case where $x-1\geq 0$ first. Then $x\geq 1$, and it trivially follows that $x+3\geq 0$ as well. So for now we can write
\begin{align}f(x) = |x+3|-|x-1| &= \begin{cases} x+3-(x-1)&\text{if } x\geq 1\\\text{To be determined}&\text{otherwise }\end{cases}\\ &=  \begin{cases} 4&\text{if } x\geq 1\\\text{To be determined}&\text{otherwise }\end{cases}.\end{align}
Next let's consider the case where $x+3<0$, i.e. $x<-3$ and it trivially follows that $x-1<0$ as well. We can now write
\begin{align}f(x) = |x+3|-|x-1| &= \begin{cases} 4&\text{if } x\geq 1\\-(x+3)-(-(x-1))&\text{if } x<-3\\\text{To be determined}&\text{otherwise}\end{cases}\\ 
&=  \begin{cases} 4&\text{if } x\geq 1\\-x-3+x-1&\text{if } x<-3\\\text{To be determined}&\text{otherwise}\end{cases}\\
&=\begin{cases} 4&\text{if } x\geq 1\\-4&\text{if } x<-3\\\text{To be determined}&\text{otherwise}\end{cases}.\end{align}
Lastly, we should consider the case where $-3 \leq x<1$. Then $x+3\geq 0$ and $x-1<0$, so finally
\begin{align}f(x) = |x+3|-|x-1| &= \begin{cases} 4&\text{if } x\geq 1\\x+3-(-(x-1))&\text{if } -3\leq x < 1\\-4&\text{if }x<-3\end{cases}\\ 
&=\begin{cases} 4&\text{if } x\geq 1\\x+3+x-1&\text{if } -3\leq x < 1\\-4&\text{if }x<-3\end{cases}\\
&=\begin{cases} 4&\text{if } x\geq 1\\2x+2&\text{if } -3\leq x < 1\\-4&\text{if }x<-3\end{cases}.
\end{align}
And that is the final result.
A: HINT:Split the function into 3 intervals,$(-\infty,-3],(-3,1],(1,+\infty)$
A: know that in every segment, the graph of $f$ is a line. you only need to know the $x$ values where the graph has a cusp. that happens at the critical numbers $3$ and $1$ now take one point to the left of the smallest and one to right of the largest critical numbers. evaluate the function at these points and join them by straight line segments.
