# Shift of discrete unit step function

I have $x[n]$ which is discrete unit step function where for $n < 0$, $x[n] = 0$. For $n \geq 0$, $x[n] = 1$. Now, if I have $x[n-4]$, the $x[n]$ is shifted to the right by $4$. Now, if I have $x[-n]$, then $x[n]$ is flipped. So then, when I have $x[4-n]$, then shouldn't it be the following: $n \leq -4, x[n] = 1\text{; } n > -4, x[n] = 0$?

But the graph shows the following:

What am I missing? Why is what I thought wrong?

• Check the value of $x[4-n]$ at different values of $n$. For example at $n=2$ your claim is $y=x[4-n]=0$, but $x[4-n]=x[4-2]=x[2]=1$; so redo the calculation. (Please do not mix the $x$ with $n$, it's confusing to read!) Feb 15, 2017 at 7:52
• @stud_iisc sorry for the notation abuse. I have editted the OP. Please see comment I have left in the accepted answer. Feb 15, 2017 at 7:58
• I am completely flabbergasted by the notation. You have a function called $x$ (and with its argument written in square brackets), certainly not a great choice of name. The values of $x$ are called $y$ in the graph, while the argument is called $x$ there, but in actual usage the argument is $n$ (a real number) or some expression involving $n$. And the actual question is not about $x$, but about other anonymous functions that might be written like $n\mapsto x[4-n]$. No wonder you get confused. Feb 15, 2017 at 10:23
• The discrepancy between the graph and my notation is because I used wolfram alpha and it automatically graphs using x and y. In reference to your comment by variable naming, the standard to refer to discrete functions is to use x[n]. And I don't think I introduced any anonymous function here. So I'm not sure what you're referring to. But thanks for your input. @MarcvanLeeuwen Feb 15, 2017 at 22:46

For the unit step function $x[n] = 1$ if $n\ge0$ and $x[n] = 0$ if $n<0$.

Now, $x[4-n]=1$ if $4-n\ge 0$. So, $x[4-n]=1$ if $4 \ge n$. Thus for $n \le 4$, the function has value $1$ and $0$ otherwise, as shown in the graph.

• Hmm, doing it mathematically makes sense. But I'm not sure where I have erred in my logic at an intuitive level. Feb 15, 2017 at 7:56
• You have erred when flipping $x[n]$ . $x[4-n]$ will be flipped form of $x[n-4]$ which is $1$ for $n \ge 4$ so your function will be $1$ for $n \le 4$ . Feb 15, 2017 at 7:58
• @Christian you must need to go through the rule of shifting and scaling order, which I have explained in the answer post. Feb 15, 2017 at 8:12

Another way to look at it: The rule follows the order of first shifting then scaling and then comes the reversal. Read http://www.princeton.edu/~cuff/ele301/files/lecture1_2.pdf for more details.

So in $x[4-n]$, first shift by $4$; which yields $y=0$ for $n\leq -4$ and $y=1$ otherwise.

Now reverse $y$ to get $x[4-n]$; which yields $x[4-n]=0$ for $n \geq 4$ and $x[4-n]=1$ otherwise. (as shown in the figure by OP in the question details.)

• This is actually really helpful. But small question. When we first do a shift, aren't we shifting x[n] left by 4? So then, for all values of n greater than -4, it should be right? But I believe you have written it the other way around? Feb 15, 2017 at 22:26
• Thanks @Christian, indeed it was a typo! Feb 16, 2017 at 3:54