# Why is this the inverse of a Enigma Machine rotor?

I am learning about how the Enigma Machine works and I found this example of one letter being encrypted by an Enigma Machine. It shows the letter "G" going through three rotors and then it goes into the reflector, then back into the inverse rotors. This is where I get confused.

The rotors are

Rotor I:   BDFHJLCPRTXVZNYEIWGAKMUSQO
Rotor II:  AJDKSIRUXBLHWTMCQGZNPYFVOE
Rotor III: EKMFLGDQVZNTOWYHXUSPAIBRCJ
Reflector: ABCDEFGHIJKLMNOPQRSTUVWXYZ  # not sure if this matters
YRUHQSLDPXNGOKMIEBFZCWVJAT


I would think that the inverse of the rotors would just be each rotor reversed like this.

Inversed Rotor I:   OQSUMKAGWIEYNZVXTRPCLJHFDB
Inversed Rotor II:  EOVFYPNZGQCMTWHLBXURISKDJA
Inversed Rotor III: JCRBIAPSUXHYWOTNZVQDGLFMKE


but on the example I linked to

Inversed Rotor I:   TAGBPCSDQEUFVNZHYIXJWLRKOM
Inversed Rotor II:  AJPCZWRLFBDKOTYUQGENHXMIVS


I don't see any relation between the rotor and the inversed versions of them. So, is this example wrong, or am I missing something?

The example is using a shorthand notation for the rotors that somewhat obscures the way they actually work. For example, the first rotor in your example, BDFHJLCPRTXVZNYEIWGAKMUSQO, actually applies the following permutation of the alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
BDFHJLCPRTXVZNYEIWGAKMUSQO


Applying this rotor in the reverse direction thus, obviously, gives the inverse permutation:

BDFHJLCPRTXVZNYEIWGAKMUSQO
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
ABCDEFGHIJKLMNOPQRSTUVWXYZ


Now, the same inverse permutation can also be written equivalently as:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
TAGBPCSDQEUFVNZHYIXJWLRKOM


You can check that these are, indeed, the same permutation: both map AT, BA, CG, and so on. The only difference is the order in which the individual input/ouput letter pairs are listed: in the first version, they are sorted by the output letter, while in the second version they are sorted by the input letter.

Now, the page you're reading is using a shorthand notation where the permutations are always sorted by the input letter, and only the output letters are actually shown. This gives a nice and compact notation, but it does make it a bit harder to e.g. see whether two permutations are actually inverses of each other.

This example is correct.

The inversed versions are the inverse permutation; that is, if the forward direction is the permutation $P$, then the inverse permutation $P^{-1}$ has the property that $P^{-1}(P(X)) = X$ for all $X$. That is, if $X$ is a plaintext letter, and we run it through in the forward direction (giving us $P(X)$), and then run it through in the backwards direction (giving us $P^{-1}(P(X))$), that's what we started out with.

In the context of Engima, this is what we want. For simplicity, let us consider the one rotor case; we have a rotor $P$ and a reflector $R$ (and remember that $R(R(X)) = X$. In this case, the Engima operation is $P^{-1}(R(P(X)))$. If we apply it again, then the result of that is $P^{-1}(R(P(P^{-1}(R(P(X))))))$; this can be simplified by noticing that $P(P^{-1}(R(P(X))))$ is the same as $R(P(X))$, and so we can simplify the result to $P^{-1}(R(R(P(X))))$; which can further be simplified to $P^{-1}(P(X))$, which can be simplified to $X$; the original plaintext letter. The three rotor case is the same, except that there are more terms (and you need to do more cancelling before you get to the final result).

That said; we can see how their rotors and their inverse rotors are related. For example, if we take the letter 'A', and send it to their Rotor I example, we get the letter 'B'. Then, if we take the letter 'B', and send it through the Inversed Rotor I, we get back the letter 'A'. In general, if their rotor has letter $i$ in position $j$, then the inverse rotor will have letter $j$ in position $i$.