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 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:

• is a **graph labelled by resistances**. So, it consists of a finite set of **nodes**, a finite set of **edges**, two functions

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

that labels each edge with its **resistance**.

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

• is another map of graphs labelled by resistances, where 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** flowing along each edge This is described by a function

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

describing the voltage across each edge

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

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

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

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**

such that

for each 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

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

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

or

The **principle of minimum power** says that:

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

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 by adding some multiple of a function

If this other function vanishes at the terminals:

then doesn’t change at the terminals as we change the number

Now suppose **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

whenever

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 by making it lie on a linear subspace.

We can go ahead and start working out the derivative:

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

The principle of minimum power says this is zero whenever is a function that vanishes at terminals. By linearity, it’s enough to consider functions that are zero at every node except one node that is not a terminal. By linearity we can also assume

Given this, the only nonzero terms in the sum

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

So, the principle of minimum power says precisely

for all nodes 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 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

and Ohm’s law says

Putting these together,

so the principle of minimum power merely says that

for any node 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 is a terminal, the quantity

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

We’ll call this the **current at the terminal** This is something we can measure even when our circuit has a black box around it:

So is the potential at the terminal 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:

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

that are compatible with our choice of and Here **compatible** means that

and

whenever but also

for every and

whenever (The last two equations combine Kirchoff’s laws and Ohm’s law.)

There either exist and 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

and potentials and currents in

Remember, is our set of inputs and is our set of outputs.

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

Here is the category where morphisms are circuits made of resistors, while is the category where morphisms are linear relations.

More precisely, here is the category

• an object of is a finite set;

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

having as its set of inputs and as its set of outputs;

• we compose morphisms in 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

• an object of is a finite-dimensional real vector space;

• a morphism from to is a **linear relation** meaning a linear subspace of the vector space

• we compose a linear relation and a linear relation in the usual way we compose relations, getting:

### Next steps

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

There are some nuances I’ve glossed over, like the difference between inputs and outputs as elements of and and their images in 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.

Perhaps next time I will clarify the nuances by doing an example.