\documentclass{article}
\usepackage{amsmath}
\usepackage{../matrixAMS}
\usepackage[pdftex]{graphicx}
\usepackage{multicol}
\usepackage{linalg}
\title{Math 2270-2 Spring 2012\\ Computer Lab 2}
\date{}
\begin{document}
\maketitle
This lab was written by Professor Chris Cashen in his Postdoc years at Utah. He is currently in 2012 at the French research institute
{\em Laboratoire de Mathématiques Nicolas Oresme,
Université de Caen Basse-Normandie}. I am indebted to him for the valuable sources, and I must record here {\em Thank you Chris}!

I hope that you will agree with me, that this project is a {\em Linear Algebra Disneyland}, an adventure which connects the abstract Four Subspaces of Strang with the physics of Kirchhoff's voltage and current laws.

\includegraphics[scale=0.4]{four-subspaces-strang-image.jpeg}

Some minor display and font size changes were made.
It remains exactly the same as Chris Cashen wrote, except for typo corrections.

 {\bf Submit your project} on the due date in class as a worksheet print. {\bf Submit study group} efforts as one worksheet print with multiple names.

\medskip
Read Section 8.2 of Strang's textbook for background. Engineers should read Michael Hanke's explanation, a copy found at
{\tt http://math.utah.edu/\~{}gustafso/MichaelHanke2006.pdf} (beware of two critical typos). Therein are physical examples plus
an explanation of how to remove superfluous variables. In the DC circuit example, you can imagine
the {\em current source} to be additional information, namely an ammeter reading. Such physical examples have no capacitors nor inductors, only resistors, wires and batteries, realized as a Radio Shack project.

\subsection*{Chris Cashen's Electrical Network Maple Lab}

The main idea of this section is that in applications the four
fundamental subspaces have a physical interpretation.

Consider a graph consisting of nodes and directed edges.
To such a graph associate an incidence matrix $A$ with one row for
each edge and one column for each node.
If edge $i$ goes from node $j$ to node $k$ then set the $i, j$--entry
of $A$ to $-1$, the $i, k$--entry of $A$ to 1, and the other entries
of row $i$ to 0.

For example, if the graph is a triangle with nodes at the vertices
labeled 1, 2, 3 and edges from 1 to 2, from 1 to 3, and from 2 to 3,
then the incidence matrix would be:
 \[A=\begin{pmatrix}[rrr] -1 & 1 &0 \\ -1 & 0 & 1 \\ 0 & -1 &
   1 \end{pmatrix}\]

We could multiply $A$ by a vector $\vec{v}$ of dimension equal to the
number of columns = number of nodes, and this will result in a vector
of dimension equal to the number of rows of $A$= number of edges in
the graph.
Imagine that the graph is an electrical circuit and the entries of the vector $\vec{v}$ are the voltage at
the corresponding node.
Then \[A\bar{v}=\begin{pmatrix}[r] v_2-v_1\\v_3-v_1\\v_3-v_2\end{pmatrix}\]
So, $A\vec{v}$ is the vector whose components are the voltage
differences across the various edges.

The {\bf Column Space} of $A$ is the collection of all linear combinations
of the columns of $A$, which is the same as the collection of vectors
$A\vec{v}$ for all possible input vectors $\vec{v}$.

Conversely, Kirchhoff's Voltage Law says that the sum of voltages differences
around a loop in the graph must be zero.
For any vector  $\vec{d}$ of voltage differences satisfying Kirchhoff's Law
there is a choice of voltage vector $\vec{v}$ such that
$A\vec{v}=\vec{d}$.
To see this, choose the voltage of one node arbitrarily. The voltage
differences then tell you the voltage at adjacent nodes, and so on.

You should think about why Kirchhoff's Law implies that this procedure works.

So, the column space of $A$ has a physical interpretation as the set
of voltage differences satisfying Kirchhoff's Voltage Law.

The {\bf Nullspace} of $A$ is the set of all vectors that give zero voltage difference
across each edge. This is true if and only if all the voltages are the
same, so the nullspace is the one dimensional space consisting of
vectors with all components equal.

Ohm's Law says that Voltage = Current $\times$ Resistance.
If we assume that each edge has resistance $1\Omega$ (1 Ohm) then the
current through the edge in Amps is equal to the voltage difference
across the edge in Volts.

Kirchhoff's Current Law says that the current flowing in to node
equals the current flowing out. If $\vec{c}$ is a vector whose
components are the currents through the various edges, then
\[A^T\vec{c}=
\begin{pmatrix}[rrr] -1&-1&0\\1&0&-1\\0&1&1\end{pmatrix}\begin{pmatrix}c_1\\c_2\\c_3\end{pmatrix}=
\begin{pmatrix}[r] -c_1-c_2\\c_1-c_3\\c_2+c_3\end{pmatrix}\]

Kirchhoff's Current Law is satisfied if and only if
$A^T\vec{c}=\vec{0}$, so the {\bf Left Nullspace} of $A$ has a physical
interpretation, it is the set of vectors whose components are currents
satisfying this Law.

Now suppose that we introduce an external current $s$ flowing into
node 1 and ground node 3. The grounded node has voltage zero,
and has net current $s$ flowing out. For the other nodes, the current
flowing in matches the current flowing out, so the circuit satisfies
the equation:
\[A^TA\vec{v}=\begin{pmatrix}[r] s\\0\\-s\end{pmatrix}\]

We can find the voltage at each node by solving this equation. Recall
that we know the nullspace is one dimensional, so there is exactly one
free column. We have grounded a node, which means we have set the free
variable $v_3=0$, and we then solve for a particular solution.

Finally, we could have different resistances across the edges. We
account for this using a square matrix $C$ whose $i,i$ entry is
$\displaystyle\frac{1}{\text{resistance of edge } i}$.

Suppose edge 3 has resistance $2\Omega$. Then:
\[C=\begin{pmatrix}1&0&0\\0&1&0\\0&0&\frac{1}{2}\end{pmatrix}\]

To find the voltages solve the equation:
\[A^TCA\begin{pmatrix}v_1\\v_2\\0\end{pmatrix}=\begin{pmatrix}[r] s\\0\\-s\end{pmatrix}\]

Then, once the voltages are known, find the currents through each edge
by computing $CA\vec{v}$.



\newpage
{\large\bf Problem}: For the following network diagram, find the voltage at each numbered node and the current flow across each numbered edge, given the following assumptions:


\begin{multicols}{2}
{\bf Figure 2}. The resistance across each edge is $1\Omega$ except for edges $e2$ and $e9$, which have resistance $5\Omega$. There is a current of 12A that enters node 1 from the top, and a current of 12A the exits node 7 from the bottom.

\includegraphics[height=5in]{lab2circuit}
\end{multicols}

End of Chris Cashen's maple lab.

\subsection*{Physical Interpretation of the Four Fundamental Subspaces}

\def\Image{\mathop{\bf Image}\nolimits}
\def\Ker{\mathop{\bf Kernel}\nolimits}
\begin{center}
\begin{tabular}{lcl@{\hspace{6ex}}p{0.5\linewidth}}
$\Image(A)$ &=& Column Space of $A$ & All vectors $\vec{v}$ with component $v_i$ = voltage difference across edge $i$. \\
$\Ker(A)$ &=& Nullspace of $A$ & Set of node potential vectors  $\vec{x}$ such that all edge voltage differences are zero.$^1$ \\
$\Ker(A^T)$ &=& Left Nullspace of $A$ & Kirchhoff's Current Law (KCL). \\[1ex]
$\Image(A^T)$ &=& Row Space of $A$ & No useful physical interpretation (yet).
\end{tabular}
\end{center}
\footnote{Literature will write {\em voltage at node $i$}, which means voltage difference between node $i$ and the reference node. The reference (mass) node could be a diagram node, but in engineering literature it is likely removed from the diagram, in order to decrease the variable count. A possible way to remove a node with assigned variable $x_i$ is to set it to zero, a physically unmotivated but effective algebraic trick. The logic? If the plan is to find the voltage differences, then the value at the reference node will be subtracted twice, hence the actual value cancels, so you may as well take it to be zero, to reduce the algebra.}
\end{document} 