Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)$?

share|cite|improve this question
up vote 5 down vote accepted

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)$$


$$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


share|cite|improve this answer
You gave a nice simple answer. However you are not actually "replacing" the inequality terms. For example in your final equation is still $0$ when $x<0$ which was not stated in the peice-wise. I thought it would be more of a "replacment" when $x<0$ is undefined. You can check my answer if you have time. – Arbuja Jan 3 at 20:44

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)$.

share|cite|improve this answer

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.


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..


The formula is then converted into..


Thus my converted result is...


share|cite|improve this answer
It's really not standard practice to define a domain by purposefully making the formula invalid for certain values - much better to explicitly state the domain and leave a simpler formula. This is to say that a formula like:$$f(x)=\frac{2x}{x+|x|}$$ implicitly expands out to "for $x>0$, $f(x)=\frac{2x}{x+|x|}$" since the formula doesn't even make sense for negative $x$. This is equivalent to "for $x>0$, $f(x)=1$, which is far clearer. That is to say, if you expand the statements to rigorous statements, definitions of domain like you have must fall out of the equation. – Milo Brandt Jan 1 at 21:37
@MiloBrandt Thank you for improving on my notions. I will edit my answer. I guess I wanted to find an alternate way to restricting the function especially when seeing it on a graph. – Arbuja Jan 1 at 22:11

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$.

share|cite|improve this answer

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.

share|cite|improve this answer
The translation is $${\cal U}(x - a \ge 0) = u(x - a) \\ {\cal U}(x - a > 0) = u(x - a - \epsilon) \\ {\cal U}(a \le x \le b) = {\cal U}(x \ge a) - {\cal U}(x \ge b) $$ where $0 < \epsilon \le 1.$ – user2468 Mar 25 '12 at 0:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.