Mathematical Statistics with Mathematica,
Colin Rose and Murry D. Smith
Appendix A.7 Working with Vectors

Working with Vectors

Thre are two completely different ways to enter a vector in Mathematica.
1
.
The List Approach: This is the standard Mathematica method. It does not distinguish between column and row vectors. Thus, Transpose cannot be used on these vectors.
2
.
The Matrix Approach: Here, a vector is entered as a special case of a matrix. This deoes distingushe between column and row vectors, so Transpose can be used with these vectors, Entering the vector this way takes more effort, but it can be less confusing and more ‘natural’ than the List approach.
Mixing the two approaches is not recommended, as this may cause error and confusion.

Vectors

the
(3x1)
columnvector
v
andthe
(1x3)
rowvector
u

v
=
a
b​​c
and
u
=(
1
2
3
)
the List approach
v={a,b,c}​​u={1,2,3}
{a,b,c}
{1,2,3}
the matrix approach
(vcol={{a},{b},{c}})//MatrixForm​​(urow={{1,2,3}})//MatrixForm
a
b
c
(
1
2
3
)

T

v

v
(1x1)

the List approach
v.v
2
a
+
2
b
+
2
c
the matrix approach
Transpose[vcol].vcol
{{
2
a
+
2
b
+
2
c
}}
Transpose[vcol].vcol//Part[#,1,1]&
2
a
+
2
b
+
2
c


u
T

u
(1x1)

the List approach
u.u
14
the matrix approach
urow.Transpose[urow]
{{14}}
urow.Transpose[urow]//Part[#,1,1]&
14


v
T

v
(3x3)

the List approach
Outer[Times,v,v]//MatrixForm
2
a
ab
ac
ab
2
b
bc
ac
bc
2
c
the matrix approach
vcol.Transpose[vcol]//MatrixForm
2
a
ab
ac
ab
2
b
bc
ac
bc
2
c

T

u

u
(3x3)

the List approach
Outer[Times,u,u]//MatrixForm
1
2
3
2
4
6
3
6
9
the matrix approach
Transpose[urow].urow//MatrixForm
1
2
3
2
4
6
3
6
9

Now Suppose :

(M={{1,0,0},{4,5,6},{0,0,9}})//MatrixForm
1
0
0
4
5
6
0
0
9

T

v
M

v
(1x1)

the List approach
v.M.v
5
2
b
+a(a+4b)+c(6b+9c)
the matrix approach
Transpose[vcol].M.vcol
{{5
2
b
+a(a+4b)+c(6b+9c)}}
the List approach
the matrix approach

Grad

the List approach
the matrix approach
Grad
the List approach
the matrix approach