# What is the difference between convolution and cross-correlation?

I've found on multiple sites that convolution and cross-correlation are similar (including the tag wiki for convolution), but I didn't find anywhere how they differ.

What is the difference between the two? Can you say that autocorrelation is also a kind of a convolution?

-

## 2 Answers

The only difference between cross-correlation and convolution is a time reversal on one of the inputs. Discrete convolution and cross-correlation are defined as follows (for real signals; I neglected the conjugates needed when the signals are complex):

$$x[n] * h[n] = \sum_{k=0}^{\infty}h[k] x[n-k]$$

$$corr(x[n],h[n]) = \sum_{k=0}^{\infty}h[k] x[n+k]$$

This implies that you can use fast convolution algorithms like overlap-save to implement cross-correlation efficiently; just time reverse one of the input signals first. Autocorrelation is identical to the above, except $h[n] = x[n]$, so you can view it as related to convolution in the same way.

Edit: Since someone else just asked a duplicate question, I've been inspired to add one more piece of information: if you implement correlation in the frequency domain using a fast convolution algorithm like overlap-save, you can avoid the hassle of time-reversing one of the signals first by instead conjugating one of the signals in the frequency domain. It can be shown that conjugation in the frequency domain is equivalent to reversal in the time domain.

-

8
This answer is fine for real signals, but Jason brought up complex-valued signals, in which case it is important to note that it is not quite the case that the "only difference is .... time reversal ..." Indeed, complex conjugates are needed on one of the two signals in the correlation formula (which one is conjugated is a matter of convention - some say to may to and some say to mah to - but both call a fruit a vegetable). On the other hand, neither signal is conjugated in the convolution formula. – Dilip Sarwate Jun 20 '12 at 2:44

1
but what does it mean that they so similar? Using some deep intuitive words! – Diego Dec 14 '12 at 17:20

For continuous convolution $$[Hf](x) \equiv f(x) * h(x) \equiv \int\mathrm{d}x' h(x-x')f(x')$$ and continuous cross-correlation $$[Gf](x) \equiv f(x) \star h(x) \equiv \int \mathrm{d}x'h^*(x'-x)f(x')$$ It's easy to show that the cross-correlation operator $G$ is the adjoint operator of the the convolution operator $H$.

Also, the convolution operation is commutative$$f(x) * h(x) = h(x) * f(x),$$ while cross-correlation does not have such a property.

$\\\\\\\\$

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 4, "mathjax_display_tex": 5, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9411311745643616, "perplexity_flag": "middle"}