|
17.4 Multiplying Vectors and Matrices
Different kinds of vector and matrix multiplication.
This multiplies each element of the vector by the scalar k.
In[1]:= k {a, b, c}
Out[1]= 
The "dot" operator gives the scalar product of two vectors.
In[2]:= {a, b, c} . {ap, bp, cp}
Out[2]= 
You can also use dot to multiply a matrix by a vector.
In[3]:= {{a, b}, {c, d}} . {x, y}
Out[3]= 
Dot is also the notation for matrix multiplication in Mathematica TE.
In[4]:= {{a, b}, {c, d}} . {{1, 2}, {3, 4}}
Out[4]= 
It is important to realize that you can use "dot" for both left- and right-multiplication of vectors by matrices. Mathematica TE makes no distinction between "row" and "column" vectors. Dot carries out whatever operation is possible. The multiplication of matrices always results in a matrix; the multiplication of a matrix and a vector results in a vector; the multiplication of vectors results in a scalar.
Here are definitions for a matrix m and a vector v.
In[5]:= m = {{a, b}, {c, d}} ; v = {x, y}
Out[5]= 
This left-multiplies the vector v by m. The object v is effectively treated as a column vector in this case.
In[6]:= m . v
Out[6]= 
You can also use dot to right-multiply v by m. Now v is effectively treated as a row vector.
In[7]:= v . m
Out[7]= 
You can multiply m by v on both sides, to get a scalar.
In[8]:= v . m . v
Out[8]= 
    
|