4
$\begingroup$

In mathematica if you run:

In[83]:= M = Table[Subscript[m, i], {i, 3}] ;
P = Table[Subscript[p, i], {i, 3}];
Q = Table[Subscript[q, i], {i, 3}];
fn[t1_, t2_] := #.# &[t1 P - t2 Q + M];
fnSym = fn[t1, t2]

Out[87]= (Subscript[m, 1] + t1 Subscript[p, 1] - 
    t2 Subscript[q, 1]) ** (Subscript[m, 1] + t1 Subscript[p, 1] - 
    t2 Subscript[q, 1]) + (Subscript[m, 2] + t1 Subscript[p, 2] - 
    t2 Subscript[q, 2]) ** (Subscript[m, 2] + t1 Subscript[p, 2] - 
    t2 Subscript[q, 2]) + (Subscript[m, 3] + t1 Subscript[p, 3] - 
    t2 Subscript[q, 3]) ** (Subscript[m, 3] + t1 Subscript[p, 3] - 
    t2 Subscript[q, 3])

The result contains lots of double asterisk **, which I cannot find anywhere in their operator list (http://reference.wolfram.com/language/tutorial/Operators.html)

So what does it mean?

$\endgroup$
2
  • $\begingroup$ If you type ** into the search field of the Documentation Center, you will find that it is the operator form of NonCommutativeMultiply $\endgroup$
    – m_goldberg
    Commented Aug 27, 2017 at 1:29
  • $\begingroup$ ** won't appear in the result unless it also appeared in your input. $\endgroup$
    – Szabolcs
    Commented Aug 27, 2017 at 10:13

1 Answer 1

9
$\begingroup$

Since this was missing from What are the most common pitfalls awaiting new users? I'll answer. ** is shorthand for NonCommutativeMultiply as can be seen with FullForm:

FullForm[a ** b ** c] // HoldForm
NonCommutativeMultiply[a, b, c]

Or highlight ** in the Front End and press F1, which should open a Search Results Notebook with a single entry for

NonCommutativeMultiply (Built-in Wolfram Language Symbol)
a ** b ** c is a general associative, but non-commutative, form of multiplication.

$\endgroup$
1
  • 1
    $\begingroup$ An addition for everybody else reading: as can be ascertained from the name of the operator, it's a useful operation if you want to define non-commutative multiplication for objects you have (e.g. in the quaternion package). $\endgroup$ Commented Aug 26, 2017 at 22:01

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