<s>[INST] 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.
 [/INST] 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.
</s>