Permutation Matricies

The key here is that it shuffles partition matricies.

The hw by example is done like so.

question 1

compute:

\(\begin{pmatrix}0 & 0 & 1\\ 1 & 0 & 0\\0 & 1 & 0\end{pmatrix} \begin{pmatrix}-2 & 3 & -1\\ 1 & 2 & 0\\2 & 1 & 3\end{pmatrix}\)

Rather than use R to calculate the result, we can look at each row of the left side. It says the result of the top row is row 2 of second matrix. Likewise, middle row is row 3 of second and bottom row is row 1 of second.

Put another way.

\[ \left( \begin{array}{c|c|c} 0 & 1 & 0 \\ \hline 0 & 0 & 1 \\ \hline 1 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{c|c|c} -2 & 1 & 2 \\ \hline 3 & 2 & 1 \\ \hline -1 & 0 & -2 \\ \end{array} \right) \] = \[ \left( \begin{array}{c} 0 x (-2\>1\>2) + 1x(3\>2\>1) + 0x(-1\>0\>-3) \\ \hline 0 x (-2\>1\>2) + 0x(3\>2\>1) + 1x(-1\>0\>-3) \\ \hline 1 x (-2\>1\>2) + 0x(3\>2\>1) + 0x(-1\>0\>-3) \\ \end{array} \right) \] = \[ \left( \begin{array}{c} 3\>2\>1 \\ \hline -1\>0\>-3 \\ \hline -2\>1\>2 \\ \end{array} \right) \] = \[ \left( \begin{array}{ccc} 3 & 2 & 1 \\ -1 & 0 & -3 \\ -2 & 1 & 2 \\ \end{array} \right) \]

Check by simply doing the matrix multiplication in R

a=matrix(c(0,0,1,1,0,0,0,1,0),ncol=3)
b=matrix(c(-2,3,-1,1,2,0,2,1,-3),ncol=3)
print(a%*%b)
##      [,1] [,2] [,3]
## [1,]    3    2    1
## [2,]   -1    0   -3
## [3,]   -2    1    2

Solving the more complex problems where I don’t know how to do it in R, but I can do via the above technique.

Its odd, that he says compute the results. Perhaps there is something in matlab which does this easier than in R.

HOMEWORK 7.2.3.2 (1/3 points)

Example: If

p = \[ \left( \begin{array}{c} 0 \\ 1 \\ 2 \\ 3 \\ \end{array} \right) \]

then P(p) =
\[ \left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) \]

Throughout, P(p) is the permutation matrix that orders the components of the vector to which it is applied according to the permutation vector p.

part a

if p = \[ \left( \begin{array}{c} 3 \\ 2 \\ 1 \\ 0 \\ \end{array} \right) \]

then P(p) =
\[ \left( \begin{array}{cccc} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ \end{array} \right) \]

part b

if p = \[ \left( \begin{array}{c} 1 \\ 0 \\ 2 \\ 3 \\ \end{array} \right) \]

then P(p) =
\[ \left( \begin{array}{cccc} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) \]

part c

if p = \[ \left( \begin{array}{c} 1 \\ 2 \\ 3 \\ 0 \\ \end{array} \right) \]

then P(p) =
\[ \left( \begin{array}{cccc} 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ \end{array} \right) \]

The remaining problems in this section are similar to above, until he gets to where he throws in Transpose matrices

(He uses the word compute here as well?)

HOMEWORK 7.2.3.4 (1 point possible)

Example: Let

p = \[ \left( \begin{array}{c} 2 \\ 0 \\ 1 \\ \end{array} \right) \]

be a permutation vector and P=P(p) be a permutation matrix. Compute
\[ \left( \begin{array}{cccc} -3 & 1 & 2 \\ 3 & 2 & 1 \\ -1 & 0 & -3 \\ \end{array} \right)P^T = \]

solution

# Ok, I am assuming since he is saying permutation matrix then
# I have to have a permutation matrix in play.
permutation_matrix=matrix(c(1,0,0,0,1,0,0,0,1),ncol=3)
permutation_matrix
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
# this is given for p...
p=matrix(c(2,0,1),ncol=1)
p
##      [,1]
## [1,]    2
## [2,]    0
## [3,]    1
# But, I need a 3x3 matrix and I know that given p above
# it really translates to:
p=matrix(c(0,0,1, 1,0,0, 0,1,0),ncol=3)
p
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    0    0    1
## [3,]    1    0    0
#P=P(p)
P= permutation_matrix %*% p 
P
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    0    0    1
## [3,]    1    0    0
Ptranspose=t(P)
Ptranspose
##      [,1] [,2] [,3]
## [1,]    0    0    1
## [2,]    1    0    0
## [3,]    0    1    0
a=matrix(c(-2,3,-1,1,2,0,2,1,-3),ncol=3)
a
##      [,1] [,2] [,3]
## [1,]   -2    1    2
## [2,]    3    2    1
## [3,]   -1    0   -3
solution=a %*% Ptranspose
solution
##      [,1] [,2] [,3]
## [1,]    1    2   -2
## [2,]    2    1    3
## [3,]    0   -3   -1