Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    $\begingroup$ Your Fold[#1-#2&,a b] is an amusing trick, but probably difficult to understand for people that are new to Mathematica. $\endgroup$ Commented Sep 26, 2022 at 14:19
  • 1
    $\begingroup$ @user293787 I remember a time when it was not even on my radar. $\endgroup$ Commented Sep 26, 2022 at 14:24
  • $\begingroup$ why does the Fold[#1 - #2 &, a b] term have the same function as (t1 . Mi . t2) ? $\endgroup$ Commented Sep 26, 2022 at 16:50
  • 2
    $\begingroup$ Focus on the first term #1 and the second term #2 of the element-wise product a b. Do a #1-#2&, you get: qm[0] qn[0] - qm[1] qn[1]. Now this becomes the first term. The second term is the next one in the list. When it folds, you get qm[0] qn[0] - qm[1] qn[1] - qm[2] qn[2]; and so it goes until the end of the list. You can study more examples from the docs. Change Fold to FoldList to see the steps. $\endgroup$ Commented Sep 26, 2022 at 16:58