\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{multicol}
\title{Math 2270-003\\ Computer Lab 2}
\date{}
\voffset=-1in
\textheight=9in
\begin{document}
\maketitle

Solve the following problem using Maple. Email the Maple worksheet as an attachment to:

 cashen@math.utah.edu

Labs are due on the last day of class.

Begin your Maple worksheet with the following lines:

\# Your Name

 \# Lab 2

\bigskip
See Section 8.2 of the text for problem background.

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}-1 & 1 &0 \\ -1 & 0 & 1 \\ 0 & -1 &
   1 \end{pmatrix}\]

We could multiply $A$ by a vector $\bar{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 $\bar{v}$ are the voltage at
the corresponding node.
Then \[A\bar{v}=\begin{pmatrix}v_2-v_1\\v_3-v_1\\v_3-v_2\end{pmatrix}\]
So, $A\bar{v}$ is the vector whose components are the voltage
differences across the various edges.

The 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\bar{v}$ for all possible input vectors $\bar{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  $\bar{d}$ of voltage differences satisfying Kirchhoff's Law
there is a choice of voltage vector $\bar{v}$ such that
$A\bar{v}=\bar{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 Nullspace of $A$ is the 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 $\bar{c}$ is a vector whose
components are the currents through the various edges, then 
\[A^T\bar{c}=\begin{pmatrix}-1&-1&0\\1&0&-1\\0&1&1\end{pmatrix}\begin{pmatrix}c_1\\c_2\\c_3\end{pmatrix}=\begin{pmatrix}-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\bar{c}=\bar{0}$, so the Left Nullspace of $A$ has a physical
interpretation, it is the 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\bar{v}=\begin{pmatrix}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
$\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}s\\0\\-s\end{pmatrix}\]

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



\newpage
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}
The resistance across each edge is $1\Omega$ except for $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{document}