# Calculation of autocorrelation - does calculation “loop”?

With a delay $l$, autocorrelation is defined as: $$r_{xx}(l) = \sum_{n=-\infty}^{\infty}x(n)x(n-l) = \sum_{n=-\infty}^{\infty}x(n)x(n+l).$$

I want to calculate the autocorrelation of a signal $$x(n) = [1,2,3,4,5]$$ with delay $l=1$. The sum starts of as $$1*2+2*3+3*4+4*5...,$$ but what happens when I reach $n=5$? Do I start of in the beginning again, i.e is the autocorrelation $$1*2+2*3+3*4+4*5 + 5*1$$ ? Am I done there?

You didn't specify for which values of $n$ your signal is not zero, so I'll assume that happens from $0$ to $4$. You have a finite sequence $x(n)$ such that

$$x(n) = 0 \qquad \forall n\in\mathbb{Z}:n<0 \ \mathrm{or} \ n>4$$

This means that $x(5)$, $x(6)$, etc. are equal to $0$. The same happens for $x(-1)$, $x(-2)$, and so on. Thus, products involving these quantities will be zero as well.

It is usual to assume that $x(n)$ is zero before and after it takes those five values. So, the autocorrelation for $l=1$ is calculated as

x(n)   = 0 0 1 2 3  4  5 0  *
x(n+1) = 0 1 2 3 4  5  0 0
-----------------
sum(0 0 2 6 12 20 0 0) = 40