# How can you rewrite piecewise functions in terms of the unit step $u(t-a)$?

Consider $u(t-a) = \begin{cases} 0, & \text{if }t<a \\ 1, & \text{if }t\geq a \end{cases}$

How can we rewrite a function like $f(t) = \begin{cases} \cos2t, & \text{if }0\leq t \lt 2\pi \\ 0, & \text{if }t\geq 2\pi \end{cases}$ in terms of the unit step function? My textbook writes this particular example as $f(t) = [1-u(t-2\pi)]\cos2t$, but I don't understand how this was formulated nor how I can formulate other piecewise functions in terms of the unit step similarly.

Consider the function $f(a,b) = u(t-a)-u(t-b); a>b$. This function is 1 in $[a,b)$ and 0 elsewhere. So, suppose you want to write $$g(x) = \begin{cases} g_1(x), & \text{if } a_1<x<a_2 \\ g_2(x), & \text{if } a_2<x<a_3\\ \ldots \end{cases}$$

Then, $$g(x) = g_1(x)f(a_2,a_1) + g_2(x)f(a_3,a_2)+\ldots$$

• I was looking for a "formula" such this one for quite a while. But, I must correct you: You should change it to $f(a,b)=u(t-b)-u(t-a)$
– E Be
Commented Sep 16, 2014 at 16:50