# Unit step function decomposition of piecewise constant function

I need to express the following in term of the unit step function:

$f(t) = \begin{cases} 0& 0\le t<3\\ -2& 3\le t<5\\ 2& 5\le t<7\\ 1& t\ge 7\end{cases}$

My solution:

$f_1(t) = 0$

$f_2(t) = 0 - 2u_2(t)$

$f_3(t) = 0 - 2u_2(t) +4u_3(t)$

$f_4(t) = 0 - 2u_2(t) +4u_3(t) - 1u_4(t)$

$f(t) = - 2u_2(t) +4u_3(t) - u_4(t)$

wondering if my working is correct

• Why is the first jump at $2$? Why is the second jump at $3$? Why is the last jump at $4$? It seems to me that the jumps should be at $3$, $5$, and $7$. – Ian Jul 28 '16 at 20:50
• why is that???? – mp12345 Jul 28 '16 at 20:54

## 2 Answers

Your coefficients are correct but as stated by Ian in the comments, you are using the wrong Heaviside functions, you should be jumping at the intervals 3,5 and 7 because that is where your piecewise function changes value:

\begin{equation} f(t)=-2u_3(t)+4u_5(t)-u_7(t) \end{equation}

Check:

\begin{equation} f(8)=-2+4-1=1 \\ f(6)=-2+4=2 \end{equation}

etc.

• see link for the definition of the heaviside function – Decebalus Jul 28 '16 at 21:04

If $u(t)$ is the unit step function, $f(t)$ can be written as

$$f(t)=-2u(t-3)+4u(t-5)-u(t-7)$$

• any explanation for this ansswer? thanks for your time – mp12345 Jul 28 '16 at 21:02
• @javahelp: Well, $u(t-3)$ implements the jump at $t=3$, $u(t-5)$ jumps at $t=5$, and $u(t-7)$ jumps at $t=7$. The factors take care of the height of the jump. First we go to $-2$ then up by $+4$ (resulting in $+2$), then again down by $1$, leaving us with a constant value of $1$ for $t>7$. – Matt L. Jul 28 '16 at 21:06