# [pstricks] Connecting nodes with boxes

Arne Hallam ahallam at iastate.edu
Tue Mar 7 19:24:50 CET 2006

The document to which you referred me was excellent.  Everything now
looks great.

Thanks very much.

\documentclass[reqno]{amsart}
\usepackage{amssymb,latexsym}
\usepackage{pstricks}
\usepackage{pst-node}

\begin{document}

\subsection{Submatrices and partitions}

Before discussing the computation of determinants using cofactors a
few definitions concerning matrices and submatrices will be useful.

\subsubsection{Submatrix}

A submatrix is a matrix formed from a matrix A by taking a subset
consisting of j rows with column elements from a set k of the
columns.  For example consider A(\{1,3\},\{2,3\}) below

\begin{aligned} A~=&~\left ( \begin{matrix}3 & 4&7 \\ 2&5& 2 \\ 1&0&4 \end{matrix} \right )\\[6pt] A(\{1,3\},\{2,3\})~=&~\left(\raisebox{-4.2ex}{ \begin{psmatrix}[rowsep=3pt,colsep=10pt] 3 &4&7 \\ 2&5& 2 \\ 1&0&4 \end{psmatrix}} \right) \psset{nodesep=.1,boxsize=.25,linearc=.3,linestyle=dashed,linecolor=blue} \ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,2}{3,2} \ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,3}{3,3} \ncbox{1,1}{1,3} \ncbox{3,1}{3,3} \\[6pt] =&~\left ( \begin{matrix} 4 &7 \\ 0&4 \end{matrix} \right )\\[4pt] \end{aligned}

The notation A(\{1,3\},\{2,3\}) means that we take the first and
third rows of A and include the second and third elements of each
row.

\subsubsection{Principal submatrix}

A principal submatrix is a  matrix formed from a square matrix A by
taking a subset consisting of n rows and column elements from the
same numbered columns.  For example consider A(\{1,3\},\{1,3\})
below

\begin{aligned} A~=&~\left ( \begin{matrix}3 & 4&7 \\ 2&5& 2 \\ 1&0&4 \end{matrix} \right )\\[6pt] A(\{1,3\},\{1,3\})~=&~\left(\raisebox{-4.2ex}{ \begin{psmatrix}[rowsep=3pt,colsep=10pt] 3 &4&7 \\ 2&5& 2 \\ 1&0&4 \end{psmatrix}} \right) \psset{nodesep=.1,boxsize=.25,linearc=.3,linestyle=dashed,linecolor=blue} \ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,1}{3,1} \ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,3}{3,3} \ncbox{1,1}{1,3} \ncbox{3,1}{3,3} \\[6pt] =&~\left ( \begin{matrix} 3 &7 \\ 1&4 \end{matrix} \right )\\[4pt] \end{aligned}

\subsubsection{Minor}

A minor is the determinant of a square submatrix of the matrix A.
For example consider $|\, A(\{2,3\},\{1,3\})\, |$.

\begin{aligned}
A~=&~\left (
\begin{matrix}3 & 4&7 \\
2&5& 2 \\
1&0&4
\end{matrix} \right )\\[4pt]
A(\{2,3\},\{1,3\})~=&~\left(\raisebox{-4.1ex}{
\begin{psmatrix}[rowsep=3pt,colsep=10pt]
3 &4&7 \\
2&5& 2 \\
1&0&4
\end{psmatrix}} \right)
\psset{nodesep=.1,boxsize=.25,linearc=.3,linestyle=dashed,linecolor=blue}
\ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,1}{3,1}
\ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,3}{3,3}
\ncbox{2,1}{2,3} \ncbox{3,1}{3,3}
\\[6pt]
=&~\left (
\begin{matrix}
2  &2 \\
1&4
\end{matrix}
\right )\\[4pt]
|A\,(\{2,3\},\{1,3\})\, | ~=&~6
\end{aligned}

\subsubsection{Principal minor}

A principal minor is the determinant of a principal submatrix of A.
For example consider $|\,A(\{1,2\},\{1,2\})\,|$.

\begin{aligned}
A~=&~\left (
\begin{matrix}3 & 4&7 \\
2&5& 2 \\
1&0&4
\end{matrix} \right )\\[4pt]
A(\{1,2\},\{1,2\})~=&~\left(\raisebox{-4.1ex}{
\begin{psmatrix}[rowsep=3pt,colsep=10pt]
3 &4&7 \\
2&5& 2 \\
1&0&4
\end{psmatrix}} \right)
\psset{nodesep=.1,boxsize=.25,linearc=.3,linestyle=dashed,linecolor=blue}
\ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,1}{3,1}
\ncbox[nodesep=.2,linestyle=solid,linecolor=red]{1,2}{3,2}
\ncbox{1,1}{1,3} \ncbox{2,1}{2,3}
\\[6pt]
=&~\left (
\begin{matrix}
3  &4 \\
2&5
\end{matrix}
\right )\\[4pt]
|A\,(\{1,2\},\{1,2\})\, | ~=&~7
\end{aligned}

Let A =(a$_{ij}$) be any n $\times$ n .  The {\bf leading principle
minors} of A are the n determinants:

$$D_k~=~\left[\, \begin{matrix} a_{11}&a_{12}&\dots&a_{1k}\\ a_{21}&a_{22}&\dots&a_{2k}\\ \vdots&\vdots&\ddots&\vdots\\ a_{k1}&a_{k2}&\dots&a_{kk} \end{matrix}\, \right], \quad \quad k~=~1, 2, \dots, n$$

D$_k$ is obtained by crossing out the last n-k columns and n-k rows
of the matrix.  Thus for k = 1, 2, 3, $\dots$ n, the leading
principle minors are, respectively

$$a_{11}, \ \left|\, \begin{matrix} a_{11}&a_{12}\\ a_{21}&a_{22} \end{matrix}\, \right|,\ \left|\, \begin{matrix} a_{11}&a_{12}&a_{13}\\ a_{21}&a_{22}&a_{23}\\ a_{31}&a_{32}&a_{33} \end{matrix}\, \right|,\ \ \dots\,, \quad \left|\, \begin{matrix} a_{11}&a_{12}&\dots&a_{1n}\\ a_{21}&a_{22}&\dots&a_{2n}\\ \vdots&\vdots&\ddots&\vdots\\ a_{n1}&a_{n2}&\dots&a_{nn} \end{matrix}\, \right|$$

\subsubsection{Cofactor}

The cofactor (denoted A$_{ij}$)  of the element a$_{ij}$ of any
square matrix A is (-1)$^{i+j}$ times the minor of A that is
obtained by including all but the i$^{\rm th}$ row and the j$^{\rm th}$ column, or alternatively the minor that is obtained by deleting
the i$^{\rm th}$ row and the j$^{\rm th}$ column.  For example
consider the matrix A.

\begin{aligned} A=& \left ( \begin{matrix} a_{11} &a_{12} &a_{13} \\ a_{21} &a_{22} &a_{23} \\ a_{31} &a_{32} &a_{33} \end{matrix} \right )~ ~= \left ( \begin{matrix} 3 & 4&7 \\ 2&5& 2 \\ 1&0&4 \end{matrix} \right ) \end{aligned}

To find the cofactor of of a$_{12}$ we first find the submatrix that
includes all rows and columns except the first and second.

\bigskip

$$A(\{2,3\},\{1,3\})~=~\left(\raisebox{-3.0ex}{  \begin{psmatrix}[rowsep=6pt,colsep=6pt]% 3 & 4&7 \\ 2&5& 2 \\ 1&0&4 \end{psmatrix}  } \right) \ncline[linecolor=red,nodesep=-0.5em]{1,1}{1,3} \ncline[linecolor=red,nodesep=-0.5em]{1,2}{3,2}~=~\left ( \begin{matrix} 2& 2\\ 1&4 \end{matrix} \right )$$

We then multiply the determinant of this matrix by (-1)$^{i+j}$. For
the example this gives

\begin{aligned} cofactor(a_{12})~=&~A_{12} =(-1)^{3} ~ | A(\{2,3\},\{1,3\}| ~=~(-1)^{3} ~\left | \, \begin{matrix} 2&2 \\ 1&4 \end{matrix} \, \right | \\[3pt] ~=&~(-1)^{3} ~(6)~=~-6 \end{aligned}

\subsection{Computing determinants using cofactors}

\subsubsection{Definition of a cofactor expansion}

The determinant of a square matrix A can be found inductively using
the following formula

$$\det\,\, A~=~|\, A\, | ~=~\sum_{j=1}^{n} ~a_{ij}\, A_{ij}$$

where i denotes the i$^{\rm th}$ row of the matrix A.  This is
called an expansion of $\mid$A$\mid$ by column i of A.  The result
is the same for any other row.  This can also be done for columns
letting the sum range over i instead of j.

\subsubsection{Examples}

\begin{description}

\item[1]

Consider as an example the following 2x2 matrix and expand using the
first row

\begin{displaymath}
\begin{aligned}
B~=& \left (\begin{matrix}
4&3 \\
1& 2
\end{matrix}
\right ) \\
~&~ \\
| B |~=&~4*(-1)^{2} *(2)~+~3*(-1)^{3} *(1)\,\, =\,\, 8\, -\, 3\,\,
=\,\, 5
\end{aligned}
\end{displaymath}

where the cofactor of 4 is (-1)$^{{(1+1)}}$ times the submatrix that
remains when we delete row and column 1 from the matrix B while the
cofactor of 3 is (-1)$^{{ (1+2)}}$ times the submatrix that remains
when we delete row 1 and column 2 from the matrix B.  In this case
each the principle
submatrices are just single numbers so there is no need to formally
compute a determinant. \\

\item[2]

Now consider a 3x3 matrix B.

\begin{displaymath}
B= \left (
\begin{matrix}1 & 2&3 \\
0&5& 2 \\
1&0&4
\end{matrix}
\right )
\end{displaymath}

If we expand using the first row of the matrix, the relevant minors
are

\begin{aligned} cofactor(b_{11})~=&~B\left(\{2,3\},\{2,3\}\right)~=~\left|\raisebox{-3.0ex}{  \begin{psmatrix}[rowsep=6pt,colsep=6pt]% 1 &2&3 \\ 0&5& 2 \\ 1&0&4 \end{psmatrix}  } \right| \ncline[linecolor=red,nodesep=-0.5em]{1,1}{1,3} \ncline[linecolor=red,nodesep=-0.5em]{1,1}{3,1}\\[4pt] cofactor(b_{12})~=&~B\left(\{2,3\},\{1,3\}\right)~=~\left|\raisebox{-3.0ex}{  \begin{psmatrix}[rowsep=6pt,colsep=6pt]% 1 &2&3 \\ 0&5& 2 \\ 1&0&4 \end{psmatrix}  } \right| \ncline[linecolor=red,nodesep=-0.5em]{1,1}{1,3} \ncline[linecolor=red,nodesep=-0.5em]{1,2}{3,2}\\[4pt] cofactor(b_{13})~=&~B\left(\{2,3\},\{1,2\}\right)~=~\left|\raisebox{-3.0ex}{  \begin{psmatrix}[rowsep=6pt,colsep=6pt]% 1 &2&3 \\ 0&5& 2 \\ 1&0&4 \end{psmatrix}  } \right| \ncline[linecolor=red,nodesep=-0.5em]{1,1}{1,3} \ncline[linecolor=red,nodesep=-0.5em]{1,3}{3,3} \end{aligned}

The determinant is then

\begin{displaymath}
\begin{aligned}
| B | ~=&~1*(-1)^{2}\,\, \left |
\begin{matrix}5&2 \\
0&4
\end{matrix} \right |
~+~2*(-1)^{3}\,\, \left |
\begin{matrix}
0&2 \\
1&4\end{matrix} \, \right | ~+~ 3*(-1)^{4} ~\left |
\begin{matrix}
0&5 \\
1&0\end{matrix}
\, \right |  \\[4pt]
=&~(1)*(20)\, +\, (-2)*(-2)\, +\, 3*(-5)~=~9
\end{aligned}
\end{displaymath}

We can also compute it using the third row of the matrix

\begin{displaymath}
\begin{aligned}
B=& \left (
\begin{matrix}
1 & 2&3 \\
0&5&2 \\
1&0&4
\end{matrix}
\right ) \\
~&~ \\
| B | ~=&~1*(-1)^{4}\,\, \left |
\begin{matrix}
2&3 \\
5&2
\end{matrix}
\right | ~+~0*(-1)^{5}\,\, \left |
\begin{matrix}
1&3 \\
0&2
\end{matrix}\, \right |
~+~ 4*(-1)^{6} ~\left | \begin{matrix}
1&2 \\
0&5\end{matrix}
\, \right |  \\
=&~(1)*(-11)\, +\, (0)*(2)\, +\, (4)*(5)~=~9
\end{aligned}
\end{displaymath}

or the first column

\begin{displaymath}
\begin{aligned}
B=& \left (
\begin{matrix}
1 & 2&3 \\
0&5& 2 \\
1&0&4
\end{matrix}
\right ) \\
~&~ \\
| B |~=&~1*(-1)^{2}\,\, \left |
\begin{matrix}5&2 \\
0&4\end{matrix} \right |
~+~0*(-1)^{3}\,\, \left |
\begin{matrix}2&3 \\
0&4\end{matrix}\, \right |
~+~ 1*(-1)^{4}
~\left | \begin{matrix}2&3 \\
5&2\end{matrix}\, \right |  \\
=&~(1)*(20)\, +\, (0)*(-8)\, +\, (1)*(-11)~=~9
\end{aligned}
\end{displaymath}

\item[3]

Consider the following 3x3 matrix

$$A=~ \left( \begin{matrix} -1&2&4 \\ 2&1&-3 \\ -1&2&0 \end{matrix} \right )$$

The determinant of A computed using the cofactor expansion along the
third row is given by

\begin{displaymath}
\begin{aligned}
| A | ~=&~-1*(-1)^{4}\,\, \left |
\begin{matrix}
2&4 \\
1&-3
\end{matrix}
\right | ~+~2*(-1)^{5}\,\, \left |
\begin{matrix}
-1&4 \\
2&-3
\end{matrix}\, \right |
~+~ 0*(-1)^{6} ~\left | \begin{matrix}
-1&2 \\
2&1\end{matrix}
\, \right |  \\
=&~(-1)*(-10)\, +\, (-2)*(-5)\, +\, (0)*(-5)~=~20
\end{aligned}
\end{displaymath}

\end{description}
\end{document}

At 11:43 PM 3/6/2006, you wrote:
>Arne Hallam wrote:
>>I did and could not find any in the material on the web.
>>I am not interesting in drawing  a circlular line from one node to
>>another but a box that is not rectangular from one node to another.
>>Maybe I am missing a part of the documentation.
>
>http://tex.loria.fr/graph-pack/pstricks/pst-doc1.pdf
>
>Herbert
>
>
>_______________________________________________
>pstricks mailing list
>pstricks at tug.org
>http://tug.org/mailman/listinfo/pstricks

with all thy getting get understanding -- Proverbs 4:7.

In the wildness of speculation it has been suggested (of course more
in jest than in earnest), that Europe ought to grow its corn in
America, and devote itself solely to manufactures and commerce, as
the best sort of division of the labour of the globe -- Thomas
Malthus, An Essay on the Principle of Population Book III, Chapter XII.

Arne Hallam
Department of Economics
Iowa State University
Ames, IA 50011

Work      515-294-5861
FAX:      515-294-0221
Home:  515-292-8739

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20060307/0f2350ec/attachment.html