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.

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

“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.

Yes, good point!

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’.

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.

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

somepart in the theory we’re developing! Brendan?Very interesting. Knowing the input and output, can we tell something about the parts that are inside the black box?

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 arerealizable. Another is: given a realizable transfer matrix, which circuits can realize it? This question is calledcircuit synthesis. Another question is how to find aminimalsynthesis—one with the fewest parts. There’s a lot to say about all these issues.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.

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!

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.