WOLFRAM LANGUAGE TUTORIAL

Multiplying Vectors and Matrices

cv, cm, etc.multiply each element by a scalar
u.v, v.m, m.v, m1.m2, etc.vector and matrix multiplication
Cross[u,v]vector cross product (also input as )
Outer[Times,t,u]outer product
KroneckerProduct[m1,m2,]Kronecker product

Different kinds of vector and matrix multiplication.

This multiplies each element of the vector by the scalar .
In[1]:=
Click for copyable input
Out[1]=
The "dot" operator gives the scalar product of two vectors.
In[2]:=
Click for copyable input
Out[2]=
You can also use dot to multiply a matrix by a vector.
In[3]:=
Click for copyable input
Out[3]=
Dot is also the notation for matrix multiplication in the Wolfram Language.
In[4]:=
Click for copyable input
Out[4]=

It is important to realize that you can use "dot" for both left and rightmultiplication of vectors by matrices. The Wolfram Language makes no distinction between "row" and "column" vectors. Dot carries out whatever operation is possible. (In formal terms, contracts the last index of the tensor with the first index of .)

Here are definitions for a matrix and a vector .
In[5]:=
Click for copyable input
Out[5]=
This leftmultiplies the vector by . The object is effectively treated as a column vector in this case.
In[6]:=
Click for copyable input
Out[6]=
You can also use dot to rightmultiply by . Now is effectively treated as a row vector.
In[7]:=
Click for copyable input
Out[7]=
You can multiply by on both sides to get a scalar.
In[8]:=
Click for copyable input
Out[8]=

For some purposes, you may need to represent vectors and matrices symbolically without explicitly giving their elements. You can use Dot to represent multiplication of such symbolic objects.

Dot effectively acts here as a noncommutative form of multiplication.
In[9]:=
Click for copyable input
Out[9]=
It is, nevertheless, associative.
In[10]:=
Click for copyable input
Out[10]=
Dot products of sums are not automatically expanded out.
In[11]:=
Click for copyable input
Out[11]=
You can apply the distributive law in this case using the function Distribute, as discussed in "Structural Operations".
In[12]:=
Click for copyable input
Out[12]=

The "dot" operator gives "inner products" of vectors, matrices, and so on. In more advanced calculations, you may also need to construct outer or Kronecker products of vectors and matrices. You can use the general function Outer or KroneckerProduct to do this.

The outer product of two vectors is a matrix.
In[13]:=
Click for copyable input
Out[13]=
The outer product of a matrix and a vector is a rank three tensor.
In[14]:=
Click for copyable input
Out[14]=

Outer products are discussed in more detail in "Tensors".

The Kronecker product of a matrix and a vector is a matrix.
In[15]:=
Click for copyable input
Out[15]=
The Kronecker product of a pair of 2×2 matrices is a 4×4 matrix.
In[16]:=
Click for copyable input
Out[16]=