## Network Theory (Part 32)

Okay, today we will look at the ‘black box functor’ for circuits made of resistors. Very roughly, this takes a circuit made of resistors with some inputs and outputs:

and puts a ‘black box’ around it:

forgetting the internal details of the circuit and remembering only how the it behaves as viewed from outside. As viewed from outside, all the circuit does is define a relation between the potentials and currents at the inputs and outputs. We call this relation the circuit’s behavior. Lots of different choices of the resistances $R_1, \dots, R_6$ would give the same behavior. In fact, we could even replace the whole fancy circuit by a single edge with a single resistor on it, and get a circuit with the same behavior!

The idea is that when we use a circuit to do something, all we care about is its behavior: what it does as viewed from outside, not what it’s made of.

Furthermore, we’d like the behavior of a system made of parts to depend in a simple way on the external behaviors of its parts. We don’t want to have to ‘peek inside’ the parts to figure out what the whole will do! Of course, in some situations we do need to peek inside the parts to see what the whole will do. But in this particular case we don’t—at least in the idealization we are considering. And this fact is described mathematically by saying that black boxing is a functor.

So, how do circuits made of resistors behave? To answer this we first need to remember what they are!

### Review

Remember that for us, a circuit made of resistors is a mathematical structure like this:

It’s a cospan where:

$\Gamma$ is a graph labelled by resistances. So, it consists of a finite set $N$ of nodes, a finite set $E$ of edges, two functions

$s, t : E \to N$

sending each edge to its source and target nodes, and a function

$r : E \to (0,\infty)$

that labels each edge with its resistance.

$i: I \to \Gamma$ is a map of graphs labelled by resistances, where $I$ has no edges. A labelled graph with no edges has nothing but nodes! So, the map $i$ is just a trick for specifying a finite set of nodes called inputs and mapping them to $N.$ Thus $i$ picks out some nodes of $\Gamma$ and declares them to be inputs. (However, $i$ may not be one-to-one! We’ll take advantage of that subtlety later.)

$o: O \to \Gamma$ is another map of graphs labelled by resistances, where $O$ again has no edges, and we call its nodes outputs.

### The principle of minimum power

So what does a circuit made of resistors do? This is described by the principle of minimum power.

Recall from Part 27 that when we put it to work, our circuit has a current $I_e$ flowing along each edge $e \in E.$ This is described by a function

$I: E \to \mathbb{R}$

It also has a voltage across each edge. The word ‘across’ is standard here, but don’t worry about it too much; what matters is that we have another function

$V: E \to \mathbb{R}$

describing the voltage $V_e$ across each edge $e.$

Resistors heat up when current flows through them, so they eat up electrical power and turn this power into heat. How much? The power is given by

$\displaystyle{ P = \sum_{e \in E} I_e V_e }$

So far, so good. But what does it mean to minimize power?

To understand this, we need to manipulate the formula for power using the laws of electrical circuits described in Part 27. First, Ohm’s law says that for linear resistors, the current is proportional to the voltage. More precisely, for each edge $e \in E,$

$\displaystyle{ I_e = \frac{V_e}{r_e} }$

where $r_e$ is the resistance of that edge. So, the bigger the resistance, the less current flows: that makes sense. Using Ohm’s law we get

$\displaystyle{ P = \sum_{e \in E} \frac{V_e^2}{r_e} }$

Now we see that power is always nonnegative! Now it makes more sense to minimize it. Of course we could minimize it simply by setting all the voltages equal to zero. That would work, but that would be boring: it gives a circuit with no current flowing through it. The fun starts when we minimize power subject to some constraints.

For this we need to remember another law of electrical circuits: a spinoff of Kirchhoff’s voltage law. This says that we can find a function called the potential

$\phi: N \to \mathbb{R}$

such that

$V_e = \phi_{s(e)} - \phi_{t(e)}$

for each $e \in E.$ In other words, the voltage across each edge is the difference of potentials at the two ends of this edge.

Using this, we can rewrite the power as

$\displaystyle{ P = \sum_{e \in E} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)})^2 }$

Now we’re really ready to minimize power! Our circuit made of resistors has certain nodes called terminals:

$T \subseteq N$

These are the nodes that are either inputs or outputs. More precisely, they’re the nodes in the image of

$i: I \to \Gamma$

or

$o: O \to \Gamma$

The principle of minimum power says that:

If we fix the potential $\phi$ on all terminals, the potential at other nodes will minimize the power

$\displaystyle{ P(\phi) = \sum_{e \in E} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)})^2 }$

subject to this constraint.

This should remind you of all the other minimum or maximum principles you know, like the principle of least action, or the way a system in thermodynamic equilibrium maximizes its entropy. All these principles—or at least, most of them—are connected. I could talk about this endlessly. But not now!

Now let’s just use the principle of minimum power. Let’s see what it tells us about the behavior of an electrical circuit.

Let’s imagine changing the potential $\phi$ by adding some multiple of a function

$\psi: N \to \mathbb{R}$

If this other function vanishes at the terminals:

$\forall n \in T \; \; \psi(n) = 0$

then $\phi + x \psi$ doesn’t change at the terminals as we change the number $x.$

Now suppose $\phi$ obeys the principle of minimum power. In other words, supposes it minimizes power subject to the constraint of taking the values it does at the terminals. Then we must have

$\displaystyle{ \frac{d}{d x} P(\phi + x \psi)\Big|_{x = 0} }$

whenever

$\forall n \in T \; \; \psi(n) = 0$

This is just the first derivative test for a minimum. But the converse is true, too! The reason is that our power function is a sum of nonnegative quadratic terms. Its graph will look like a paraboloid. So, the power has no points where its derivative vanishes except minima, even when we constrain $\phi$ by making it lie on a linear subspace.

We can go ahead and start working out the derivative:

$\displaystyle{ \frac{d}{d x} P(\phi + x \psi)! = ! \frac{d}{d x} \sum_{e \in E} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)} + x(\psi_{s(e)} -\psi_{t(e)}))^2 }$

To work out the derivative of these quadratic terms at $x = 0,$ we only need to keep the part that’s proportional to $x.$ The rest gives zero. So:

$\begin{array}{ccl} \displaystyle{ \frac{d}{d t} P(\phi + x \psi)\Big|_{x = 0} } &=& \displaystyle{ \frac{d}{d x} \sum_{e \in E} \frac{x}{r_e} (\phi_{s(e)} - \phi_{t(e)}) (\psi_{s(e)} - \psi_{t(e)}) \Big|_{x = 0} } \\ \\ &=& \displaystyle{ \sum_{e \in E} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) (\psi_{s(e)} - \psi_{t(e)}) } \end{array}$

The principle of minimum power says this is zero whenever $\psi : N \to \mathbb{R}$ is a function that vanishes at terminals. By linearity, it’s enough to consider functions $\psi$ that are zero at every node except one node $n$ that is not a terminal. By linearity we can also assume $\psi(n) = 1.$

Given this, the only nonzero terms in the sum

$\displaystyle{ \sum_{e \in E} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) (\psi_{s(e)} - \psi_{t(e)}) }$

will be those involving edges whose source or target is $n.$ We get

$\begin{array}{ccc} \displaystyle{ \frac{d}{d x} P(\phi + x \psi)\Big|_{x = 0} } &=& \displaystyle{ \sum_{e: \; s(e) = n} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)})} \\ \\ && -\displaystyle{ \sum_{e: \; t(e) = n} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) } \end{array}$

So, the principle of minimum power says precisely

$\displaystyle{ \sum_{e: \; s(e) = n} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) = \sum_{e: \; t(e) = n} \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) }$

for all nodes $n$ that aren’t terminals.

What does this mean? You could just say it’s a set of linear equations that must be obeyed by the potential $\phi.$ So, the principle of minimum power says that fixing the potential at terminals, the potential at other nodes must be chosen in a way that obeys a set of linear equations.

But what do these equations mean? They have a nice meaning. Remember, Kirchhoff’s voltage law says

$V_e = \phi_{s(e)} - \phi_{t(e)}$

and Ohm’s law says

$\displaystyle{ I_e = \frac{V_e}{r_e} }$

Putting these together,

$\displaystyle{ I_e = \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) }$

so the principle of minimum power merely says that

$\displaystyle{ \sum_{e: \; s(e) = n} I_e = \sum_{e: \; t(e) = n} I_e }$

for any node $n$ that is not a terminal.

This is Kirchhoff’s current law: for any node except a terminal, the total current flowing into that node must equal the total current flowing out! That makes a lot of sense. We allow current to flow in or out of our circuit at terminals, but ‘inside’ the circuit charge is conserved, so if current flows into some other node, an equal amount has to flow out.

In short: the principle of minimum power implies Kirchoff’s current law! Conversely, we can run the whole argument backward and derive the principle of minimum power from Kirchhoff’s current law. (In both the forwards and backwards versions of this argument, we use Kirchhoff’s voltage law and Ohm’s law.)

When the node $n$ is a terminal, the quantity

$\displaystyle{ \sum_{e: \; s(e) = n} I_e \; - \; \sum_{e: \; t(e) = n} I_e }$

need not be zero. But it has an important meaning: it’s the amount of current flowing into that terminal!

We’ll call this $I_n,$ the current at the terminal $n \in T.$ This is something we can measure even when our circuit has a black box around it:

So is the potential $\phi_n$ at the terminal $n.$ It’s these currents and potentials at terminals that matter when we try to describe the behavior of a circuit while ignoring its inner workings.

### Black boxing

Now let me quickly sketch how black boxing becomes a functor.

A circuit made of resistors gives a linear relation between the potentials and currents at terminals. A relation is something that can hold or fail to hold. A ‘linear’ relation is one defined using linear equations.

A bit more precisely, suppose we choose potentials and currents at the terminals:

$\psi : T \to \mathbb{R}$

$J : T \to \mathbb{R}$

Then we seek potentials and currents at all the nodes and edges of our circuit:

$\phi: N \to \mathbb{R}$

$I : E \to \mathbb{R}$

that are compatible with our choice of $\psi$ and $J.$ Here compatible means that

$\psi_n = \phi_n$

and

$J_n = \displaystyle{ \sum_{e: \; s(e) = n} I_e \; - \; \sum_{e: \; t(e) = n} I_e }$

whenever $n \in T,$ but also

$\displaystyle{ I_e = \frac{1}{r_e} (\phi_{s(e)} - \phi_{t(e)}) }$

for every $e \in E,$ and

$\displaystyle{ \sum_{e: \; s(e) = n} I_e \; = \; \sum_{e: \; t(e) = n} I_e }$

whenever $n \in N - T.$ (The last two equations combine Kirchoff’s laws and Ohm’s law.)

There either exist $I$ and $\phi$ making all these equations true, in which case we say our potentials and currents at the terminals obey the relation… or they don’t exist, in which case we say the potentials and currents at the terminals don’t obey the relation.

The relation is clearly linear, since it’s defined by a bunch of linear equations. With a little work, we can make it into a linear relation between potentials and currents in

$\mathbb{R}^I \oplus \mathbb{R}^I$

and potentials and currents in

$\mathbb{R}^O \oplus \mathbb{R}^O$

Remember, $I$ is our set of inputs and $O$ is our set of outputs.

In fact, this process of getting a linear relation from a circuit made of resistors defines a functor:

$\blacksquare : \mathrm{ResCirc} \to \mathrm{LinRel}$

Here $\mathrm{ResCirc}$ is the category where morphisms are circuits made of resistors, while $\mathrm{LinRel}$ is the category where morphisms are linear relations.

More precisely, here is the category $\mathrm{ResCirc}:$

• an object of $\mathrm{ResCirc}$ is a finite set;

• a morphism from $I$ to $O$ is an isomorphism class of circuits made of resistors:

having $I$ as its set of inputs and $O$ as its set of outputs;

• we compose morphisms in $\mathrm{ResCirc}$ by composing isomorphism classes of cospans.

(Remember, circuits made of resistors are cospans. This lets us talk about isomorphisms between them. If you forget the how isomorphism between cospans work, you can review it in Part 31.)

And here is the category $\mathrm{LinRel}:$

• an object of $\mathrm{LinRel}$ is a finite-dimensional real vector space;

• a morphism from $U$ to $V$ is a linear relation $R \subseteq U \times V,$ meaning a linear subspace of the vector space $U \times V;$

• we compose a linear relation $R \subseteq U \times V$ and a linear relation $S \subseteq V \times W$ in the usual way we compose relations, getting:

$SR = \{(u,w) \in U \times W : \; \exists v \in V \; (u,v) \in R \mathrm{\; and \;} (v,w) \in S \}$

### Next steps

So far I’ve set up most of the necessary background but not precisely defined the black boxing functor

$\blacksquare : \mathrm{ResCirc} \to \mathrm{LinRel}$

There are some nuances I’ve glossed over, like the difference between inputs and outputs as elements of $I$ and $O$ and their images in $N.$ If you want to see the precise definition and the proof that it’s a functor, read our paper:

• John Baez and Brendan Fong, A compositional framework for passive linear networks.

The proof is fairly long: there may be a much quicker one, but at least this one has the virtue of introducing a lot of nice ideas that will be useful elsewhere.

Next time I’ll define the black box functor more carefully.

### 10 Responses to Network Theory (Part 32)

1. Nick Stokes says:

“In fact, we could even replace the whole fancy circuit by a single edge with a single resistor on it, and get a circuit with the same behavior!”

Thévenin could be mentioned here.

2. This time we use the principle of minimum power to determine what a circuit made of resistors actually does. Its ‘behavior’ is described by a functor sending circuits to linear relations between the potentials and currents at the input and output terminals. We call this the ‘black box’ functor, since it takes a circuit and puts a metaphorical ‘black box’ around it, hiding the circuit’s internal details and letting us see only how it acts as viewed ‘from outside’.

3. Peva B. says:

I just happen to read this blog. It is really interesting !

I’m almost sure that you already know about it, but it reminds me this very cool paper http://link.springer.com/article/10.1007%2FBF01843493 by Goguen in automata theory. He proves that “blackboxing an automaton” is the left adjoint of minimal realization, i.e., the simplest automaton exhibiting this behaviour.

Would that make sense to do something similar here ? The right adjoint would be something that finds the simplest passive network matching the input/output data …

Anyway, thanks for these blog posts.

• John Baez says:

There’s a lot of work on ‘minimal realizations’, trying to find the simplest circuit that has a given behavior. However, I’m afraid this would not be functorial. In fact that’s fairly easy to see, since when we compose two circuits made of a single resistor, we get a circuit made of a two resistors… but its behavior is equal to that of a circuit made of just one resistor!

But maybe the idea can be rescued. To do this, maybe we could put an equivalence relation on circuits, getting a category where the two circuits I just mentioned count as the same… and various other ‘trivial differences’ between circuits are neglected.

Nick Stokes mentioned Thévenin’s equivalence theorem—that’s the kind of thing I mean. Also see Norton’s equivalence theorem.

These theorems should definitely play some part in the theory we’re developing! Brendan?

4. Jim says:

Very interesting. Knowing the input and output, can we tell something about the parts that are inside the black box?

• John Baez says:

Yes, but only a little bit. The main thing you can tell is what currents will occur at the inputs and output given what potentials you apply to the inputs and outputs. This is sometimes called the transfer matrix. One interesting question is which transfer matrices you can actually get: which are realizable. Another is: given a realizable transfer matrix, which circuits can realize it? This question is called circuit synthesis. Another question is how to find a minimal synthesis—one with the fewest parts. There’s a lot to say about all these issues.

5. Last time I came close to describing the ‘black box functor’, which takes an electrical circuit made of resistors made of resistors and sends it to its behavior as viewed from outside. This time let’s finish the job.

6. David Jekel says:

I have been studying the inverse problem for nonlinear electrical networks, and I thought of a similar category of networks with inputs and outputs and a functor to the category of relationships. Except that instead of a resistance for each edge, I had a relationship that says what current is compatible with what voltage drop (for most purposes, I assume this is actually a bijective zero-preserving “resistance function”). These categories are useful for describing “harmonic continuation” of voltage-current functions on an electrical network. This is turn is used to create boundary value problems that will allow us to determine the resistance functions of the edges from the external behavior.

I’m looking forward to hearing more!

• John Baez says:

I want to generalize networks of linear resistors to networks of nonlinear ones using a category similar to the one you describe. Are there some particular problems you’re trying to solve, or known phenomena you’re trying to clarify? It would be nice to have something specific to shoot for.