How to rewrite a piecewise function in terms of the Heaviside function Let's say I have a piecewise function:
$$f(x) = \begin{cases}x ,& 0 \leq x \leq 1 \\1 ,& 1 \leq x\end{cases}$$
How can I rewrite this in terms of the Heaviside function $u(x-a)$?
 A: I gave a good rundown of a mechanical method here. The main idea is to change everything to Iverson brackets before finally switching to the unit step function, since there is the relationship
$$[x\geq a]=[x-a\geq0]=\begin{cases}1&\text{if }x-a\geq0\\0&\text{if }x-a<0\end{cases}=u(x-a)$$
With
$$f(x) = \begin{cases} x & 0 \leq x < 1 \\ 1 & 1 \leq x \end{cases}$$
(and assuming that the function is zero in all other cases), translation to the Iverson convention is easy:
$$f(x)=x[0 \leq x < 1]+[1 \leq x]$$
and we can then do some massaging:
$$\begin{align*}
f(x)&=x[0 \leq x < 1]+[1\leq x]\\
&=x[x \geq 0][x < 1]+[x-1 \geq 0]\\
&=x[x \geq 0][\lnot(x \geq 1)]+[x-1 \geq 0]\\
&=x[x \geq 0](1-[x \geq 1])+[x-1 \geq 0]\\
&=x[x \geq 0](1-[x-1 \geq 0])+[x-1 \geq 0]\\
&=x[x \geq 0]-x[x \geq 0][x-1 \geq 0]+[x-1 \geq 0]\\
&=x\,u(x)-x\,u(x)u(x-1)+u(x-1)\\
\end{align*}$$
where the properties $[p\text{ and }q]=[p][q]$ and $[\lnot p]=1-[p]$ of the Iverson bracket were useful.
One can do a further simplification, since $u(x)u(x-1)=[(x \geq 0)\text{ and }(x \geq 1)]=[x \geq 1]=u(x-1)$. We then finally have
$$f(x)=x\,u(x)-x\,u(x-1)+u(x-1)=x\,u(x)+(1-x)u(x-1)$$
A: At $x=0$ the slope grows of $1$ adding a term $x\cdot u(x-0)$
At $x=1$ the slope change ends subtracting a term $(x-1)\cdot u(x-1)$
So that $f(x)=x\cdot (u(x-0)-u(x-1))+u(x-1)$.
A: Given the pieces your function is made of, you want to look for functions $g(x)$ and $h(x)$ such that $f(x)=g(x)u(x)+h(x)u(x-1)$.
I let you determine the functions $g$ and $h$.
A: I have an alternate function that is equal to the peice-wise function function such that their real domains are exactly the same. I did this by artificially erasing unwanted intervals of the alternate function without using the $<$,$>$,${\le}$ signs (since @J.M.'s post attempted to replace those signs). 
(Note that this is not standard nor necessary answer as the equality for both function need not have the same exact domain).
In the case of 
$$f(x) = \begin{cases}x ,& 0 \leq x \leq 1 \\1 ,& 1 \leq x\end{cases}$$
,the piece-wise function does not include $x<0$. To do this first we must create the equivelant function 
$$\sum_{n=0}^{l}f_{n}(x)g_{n}(x)$$
Then to remove unwanted intervals of $x$ we can do the following.
$$\left(\sum_{n=0}^{l}\left(f_{n}(x)\right)^{-1}g_{n}(x)\right)^{-1}$$
Here are the possibilities of $g_{n}(x)$ to restrict the domain of two different function and fuse them.
$g_{1}(x)=-u\left(\lceil{x-a-1}\rceil+.5\right)+1\quad$ $x{\le}a\quad$, $-u\left(\lfloor{x-a}\rfloor+.5\right)+1\quad$ $x<a$
$g_{2}(x)=u\left(\lfloor{x-b}\rfloor+.5\right)\quad$ $x{\ge}b\quad$, $-u\left(\lceil{x-b-1}\rceil+.5\right)\quad$ $x>b$
$g_{3}(x)=u\left(\lfloor{x-a}\rfloor+.5\right)-u\left(\lceil{x-b-1}\rceil+.5\right)\quad$ $a{\le}x{\le}b$
Now to apply this to the peice-wise function..
$$\left(x\right)\Big(u\left(\lfloor{x}\rfloor+.5\right)-u\left(\lfloor{x-1}\rfloor+.5\right)\Big)+(1)u(\lfloor{x-1}\rfloor+.5)$$
The formula is then converted into..
$$\left(\left(x^{-1}\right)\left(u\left(\lfloor{x}\rfloor+.5\right)-u\left(\lceil{x-2}\rceil+.5\right)\right)+(1^{-1})u(\lceil{x-2}\rceil+.5)\right)^{-1}$$
Thus my converted result is...
$$\left(\left(x^{-1}\right)\left(u\left(\lfloor{x}\rfloor+.5\right)-u\left(\lceil{x-2}\rceil+.5\right)\right)+u(\lceil{x-2}\rceil+.5)\right)^{-1}$$
A: In general, assuming that the conditions $c_1, \ldots, c_n$ are mutually exclusive,
the translation would be
$$
\begin{eqnarray*}
f(x) & = &
     \begin{cases}
       f_1(x), & c_1 \\
       \ldots \\
       f_n(x), & c_n \\
     \end{cases} \\ 
& = &
f_1(x) \cdot \mathcal{U}(c_1) + \ldots + f_n(x) \cdot \mathcal{U}(c_n)
\end{eqnarray*}
$$
where $\mathcal{U}(c_n)$ is the encoding of $n$th condition.

Relevant: Superposition Principle used a lot in engineering.
