It’s that day of the year again.

Kokoro Connect’s premise made a lot of people raise their eyebrows, because really, what good can come from body-switching shenanigans? Well, let’s think about this for a second. We have a group of five kids and every once in a while, at random, they switch into the others’ bodies at random. What does that sound like? That’s right, a permutation!

Interestingly enough, the idea of connecting body-switching with permutations isn’t new. The Futurama writers did it and apparently got a new theorem out of it. What differs in the case of Kokoro Connect and Futurama is that in Futurama, the body-switching could only happen in twos. These are called transpositions. Obviously, this isn’t the case for Kokoro Connect. This doesn’t make too much of a difference since it turns out we can write out any permutation we want as a series of transpositions, but that wouldn’t be very fun for Heartseed.

We write permutations in the following way. If we let Taichi = 1, Iori = 2, Inaban = 3, Aoki = 4, and Yui = 5, we’ll have $(1 2 3 4 5)$ representing the identity permutation, when everyone’s in their own body. If Heartseed wanted to make Aoki and Yui switch places, he’d apply the following permutation

$$ \left( \begin{array}{ccccc} 1&2&3&4&5 \\ 1&2&3&5&4 \end{array} \right) $$

While it’s helpful for seeing exactly what goes where, especially when we start dealing with multiple permutations, this notation is a bit cumbersome, so we’ll only write the second line ($(12354)$) to specify a permutation.

For the purposes of this little exercise, we’ll consider applying a permutation as taking whoever’s currently in a given body. That is, say we permute Aoki and Taichi to get $(4 2 3 1 5)$. In order to get everyone back into their own bodies, we have to apply $(4 2 3 1 5)$ again, which takes Aoki, who’s in Taichi’s body, back into Aoki’s body.

So let’s begin with something simple. How many different ways are there for the characters to body switch? Both who is switched and who they switch with is entirely random. Again, since the switches aren’t necessarily transpositions, this means that we can end up with cycles like in episode 2, when Yui, Inaban, and Aoki all get switched at the same time. This can be written as $(1 2 4 5 3)$.

But this is just the number of permutations that can happen on a set of five elements, which is just 5! = 120. Of course, that includes the identity permutation, which just takes all elements to themselves, so the actual number of different ways the characters can be swapped is actually 119.

Anyhow, we can gather up all of these different permutations into a set and give it the function composition operation and it becomes a group. A group $(G,\cdot)$ is an algebraic structure that consists of a set $G$ and an operation $\cdot$ which satisfy the group axioms:

Closure: for every $a$ and $b$ in $G$, $a\cdot b$ is also in $G$

Associativity: for every $a$, $b$, and $c$ in $G$, $(a\cdot b)\cdot c = a\cdot (b\cdot c)$

Identity: there exists $e$ in $G$ such that for every $a$ in $G$, $e\cdot a = a \cdot e = a$

Inverse: for every $a$ in $G$, there exists $b$ in $G$ such that $a\cdot b = b\cdot a = e$

In this case, we can think of the permutations themselves as elements of a group and we take permutation composition as the group operation. Let’s go through these axioms.

Closure says that if have two different configurations of body swamps, say Taichi and Iori ($(2 1 3 4 5)$) and Iori and Yui ($(1 5 3 4 2)$), then we can apply them one after the other and we’d still have a body swap configuration: $(2 5 3 4 1)$. That is, we won’t end up with something that’s not a body swap. This seems like a weird distinction to make, but it’s possible to define a set that doesn’t qualify as a group. Say I want to take the integers under division as a group ($(\mathbb Z, \div)$). Well, it breaks closure because 1 is an integer and 2 is an integer but $1 \div 2$ is not an integer.

Associativity says that it doesn’t matter what order we choose to apply our operations in. If we have three swaps, say Taichi and Inaban ($(3 2 1 4 5)$), Aoki and Yui ($(1 2 3 5 4)$), and Iori and Yui $(1 5 3 4 2)$ and we want to apply them in that order. Then as long as they still happen in that order, it doesn’t matter which one we apply first. We’d have

$$((32145)(12354))(15342) = (32154)(15342) = (34152)$$

and

$$(32145)((12354)(15342)) = (32145)(14352) = (34152)$$

The identity means that there’s a configuration that we can apply and nothing will change. That’d be $(12345)$. And inverse means that there’s always a single body swap that we can make to get everyone back in their own bodies.

As it turns out, the group of all permutations on $n$ objects is a pretty fundamental group. These groups are called the symmetric groups and are denoted by $S_n$. So the particular group we’re working with is $S_5$.

So what’s so special about $S_5$? Well, as it turns out it’s the first symmetric group that’s not solvable, a result that’s from Galois theory and has a surprising consequence.

Évariste Galois was a cool dude, proving a bunch of neat stuff up until he was 20, when he got killed in a duel because of some drama which is speculated to be of the relationship kind, maybe not unlike Kokoro Connect (it probably wasn’t anything like Kokoro Connect at all). Among the things that he developed was the field that’s now known as Galois theory, which is named after him. What’s cool about Galois theory is that it connects two previously unrelated concepts in algebra: groups and fields.

One of the most interesting things that came out of Galois theory is related to the idea of solving polynomials. I’m sure we’re all familiar with the quadratic formula. Well, in case you aren’t, here it is:

$$x = \frac{-b \pm \sqrt{b^2 – 4ac}}{2a}$$

This neat little formula gives us an easy way to find the complex roots of any second degree polynomial. It’s not too difficult to derive. And we can do that for cubic polynomials too, which takes a bit more work to derive. And if we want to really get our hands dirty, we could try deriving the general form of roots for polynomials of degree four. And wait until you try to do it for degree five polynomials.

That’s because, eventually, you’ll give up. Why? Well, it’s not just hard, but it’s impossible. There is no general formula using radicals and standard arithmetic operations for the roots for any fifth degree (or higher!) polynomial. The reason behind this is because $S_5$ is the Galois group for the general polynomial of degree 5. Unfortunately, proving that fact is a bit of a challenge to do here since it took about 11 weeks of Galois theory and group theory to get all the machinery in place, so we’ll have to leave it at that.