I was reading Ted Ersek's explanation for the usage of ListCorrelate(.nb version can be found here) and noticed something confusing. It's the third example of Specifying the "overhang" using {$K_L$, $K_R$} section:

enter image description here

You may think that it's a typo at first glance, but the output is really correct. Just try it yourself:

{{a1, a2, a3, a4, 0, 0}, {0, a1, a2, a3, a4, 0}, {0, 0, a1, a2, a3, 
   a4}, {a4, 0, 0, a1, a2, a3}, {a3, a4, 0, 0, a1, a2}, {a2, a3, a4, 
   0, 0, a1}, {a1, a2, a3, a4, 0, 0}, {0, a1, a2, a3, a4, 0}, {0, 0, 
   a1, a2, a3, a4}}.{{b1}, {b2}, {b3}, {b4}, {b5}, {b6}}
Flatten[%] === ListCorrelate[{a1, a2, a3, a4}, {b1, b2, b3, b4, b5, b6}, {1, -1}]

The other 3 examples do follow the statement though.

So Ted's theory is simply incomplete but he didn't notice? Or there's some deeper reason (in compatible changes between versions etc.)?

  • $\begingroup$ Is it possible to understand {{b1}, {b2}, {b3}, {b4}, {b5}, {b6}} as {b1, b2, b3, b4, b5, b6}? $\endgroup$
    – xyz
    Sep 19, 2014 at 10:04
  • $\begingroup$ @Tangshutao I think it's better not to. As far as I understand, instead of using concepts like "row", "column" etc. Mathematica uses Level of lists (Dimensions?) when discussing matrices, which leads to a rule that is a little different from what's usually used in our Linear Algebra text book. Dot of two lists are the match of the last dimension of the former list and the first dimension of the latter list, so {a, b, c} . {x, y, z} becomes valid, which in our text book should be written as {a, b, c} . {{x}, {y}, {z}} . $\endgroup$
    – xzczd
    Sep 19, 2014 at 11:23
  • $\begingroup$ @Tangshutao And I just noticed that in fact the rule used by Mathematica is just consistent with the rule used by tensor notation. If you've ever learned about the basic tensor notation in any course, just recall it and you'll find the rule of Dot no longer that hard to understand! $\endgroup$
    – xzczd
    Sep 19, 2014 at 12:06
  • $\begingroup$ Dear xzczd, Thanks sincerely! I didn't learn about the basic tensor notation and I will read some book about it. $\endgroup$
    – xyz
    Sep 19, 2014 at 13:51
  • $\begingroup$ @Tangshutao You're welcome, without answering your question, I won't have noticed the consistency today. 教学相长 :D $\endgroup$
    – xzczd
    Sep 19, 2014 at 14:06

1 Answer 1


The fact that False is on his own web page indicates against this being a change between versions but rather something he failed to notice.

Following his equivalence we also have the last kernel element (a4) in the last place in the third row of the left matrix, an indeed that matches the actual output:

m = NestList[RotateRight, {a1, a2, a3, a4, 0, 0}, 2]

$\left( \begin{array}{cccccc} \text{a1} & \text{a2} & \text{a3} & \text{a4} & 0 & 0 \\ 0 & \text{a1} & \text{a2} & \text{a3} & \text{a4} & 0 \\ 0 & 0 & \text{a1} & \text{a2} & \text{a3} & \text{a4} \\ \end{array} \right)$

ListCorrelate[{a1, a2, a3, a4}, {b1, b2, b3, b4, b5, b6}, {1, -1}]

% === m.{b1, b2, b3, b4, b5, b6}
{a1 b1 + a2 b2 + a3 b3 + a4 b4,
 a1 b2 + a2 b3 + a3 b4 + a4 b5, 
 a1 b3 + a2 b4 + a3 b5 + a4 b6}

  • 1
    $\begingroup$ It looks like I did understand what ListCorrelate does with the third argument, but in that example above, I didn't use the right way of rotating the kernel. I wrote that a long time ago. I have to speculate that I didn't notice that the comparison returned False. I think I should use Mr. Wizard's way of rotating the kernel. When I make that change I will credit Mr. Wizard. $\endgroup$
    – Ted Ersek
    Sep 19, 2014 at 11:33
  • $\begingroup$ @TedErsek I did not think you were maintaining that page any longer. (Last updated May 16, 2004 I believe?) I am pleased to hear that you seem to be considering it. I learned a great deal from your Tips and Tricks at the time. $\endgroup$
    – Mr.Wizard
    Sep 19, 2014 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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