## Tuesday, September 1, 2015

### Linear fractional transforms and permutations

So what does group theory have to do with linear fractional transforms? I'm glad you asked. The answer is pretty complicated, though.

There's no good place to start here, so let's just dive in. This function computes the `cross-ratio` of four numbers:

```(define (cross-ratio A B C D)
(/ (* (- a b) (- c d))
(* (- a d) (- c b))))

1 ]=> (cross-ratio 1 9 5 13)

;Value: 4/3
```

There's a geometric interpretation of the cross ratio, but for the moment, just think of it as a function that takes any four numbers and produces a value.

```1 ]=> (cross-ratio 3 2 1 9)

;Value: -4/3

1 ]=> (cross-ratio 5 1 8 4)

;Value: 16/7
```

The cross ratio is preserved under linear fractional transforms:

```1 ]=> (define lft2 (make-linear-fractional-transform 3 -1 2 7))

;Value: lft2

1 ]=> (cross-ratio (lft2 3) (lft2 2) (lft2 1) (lft2 9))

;Value: -4/3

1 ]=> (cross-ratio (lft 3) (lft 2) (lft 1) (lft 9))

;Value: -4/3

1 ]=> (cross-ratio 3 2 1 9)

;Value: -4/3
```

The cross ratio is also preserved under some permutations of its arguments.

```1 ]=> (cross-ratio 3 2 1 9)

;Value: -4/3

1 ]=> (cross-ratio 1 9 3 2)

;Value: -4/3

1 ]=> (cross-ratio 2 3 9 1)

;Value: -4/3
```
but not all
```1 ]=> (cross-ratio 3 2 9 1)

;Value: 4/7

1 ]=> (cross-ratio 2 9 3 1)

;Value: 7/3
```

Now here's the interesting part. There's a linear fractional transform that will "undo" the permutation of the arguments to cross-ratio.

```1 ]=> ((make-linear-fractional-transform -1 1 0 1) 7/3)

;Value: -4/3

1 ]=> ((make-linear-fractional-transform 1 0 1 -1) 4/7)

;Value: -4/3
```
There are 24 permutations of the argument list to `cross-ratio`, and here are the equivalence classes:
```((-4/3 (1 9 3 2) (2 3 9 1) (3 2 1 9) (9 1 2 3))
(-3/4 (1 2 3 9) (2 1 9 3) (3 9 1 2) (9 3 2 1))
(3/7 (1 2 9 3) (2 1 3 9) (3 9 2 1) (9 3 1 2))
(4/7 (1 9 2 3) (2 3 1 9) (3 2 9 1) (9 1 3 2))
(7/4 (1 3 2 9) (2 9 1 3) (3 1 9 2) (9 2 3 1))
(7/3 (1 3 9 2) (2 9 3 1) (3 1 2 9) (9 2 1 3)))```
And these are the linear fractional transforms that permute among these:
```(#[linear-fractional-transform 89333 x]
#[linear-fractional-transform 89334 1/x]
#[linear-fractional-transform 89335 (1 - x)]
#[linear-fractional-transform 89403 1/(1 - x)]
#[linear-fractional-transform 89370 x/(x - 1)]
#[linear-fractional-transform 89393 (x - 1)/x])```

This is cool. Instead of thinking of a linear fractional transform as a continuous function that traces out a hyperbola, or as an interval on the real number line, we can think of a linear fractional transform as a function that computes a permutation.

Here is a function called `d3` that is defined on the symbols `a`, `b`, `c`, `d`, `e`, and `f`.

```1 ]=> (d3 'a 'b)

;Value: d
```
With six symbols, there's only 36 possible outcomes, so we can enumerate them:
```    a b c d e f
a ((e d f b a c)
b  (f e d c b a)
c  (d f e a c b)
d  (c a b f d e)
e  (a b c d e f)
f  (b c a e f d))```

Here's a hack. The identity element can be seen to be `'e`, so list that row and column first:

```    e a b c d f
e ((e a b c d f)
a  (a e d f b c)
b  (b f e d c a)
c  (c d f e a b)
d  (d c a b f e)
f  (f b c a e d))```

Now the table headers are exactly the same as the first entries in the respective rows or columns, so you can do without them.

```((e a b c d f)
(a e d f b c)
(b f e d c a)
(c d f e a b)
(d c a b f e)
(f b c a e d))```

Another weird thing is that you can permute any rows but the first, or permute any columns but the first, and still have an equivalent table.

Anyway, d3 is the "symmetry group" of a triangle. Here the operations are

```e = leave it alone
f = rotate clockwise 120 degrees
d = rotate counter-clockwise 120 degrees
a = hold vertex A in place, and flip the triangle over swapping vertex B and C
b = hold vertex B in place, and flip the triangle over swapping vertex A and C
c = hold vertex C in place, and flip the triangle over swapping vertex A and B
```
Now consider this,
```e = #[linear-fractional-transform 89333 x]
f = #[linear-fractional-transform 89393 (x - 1)/x]
d = #[linear-fractional-transform 89403 1/(1 - x)]
a = #[linear-fractional-transform 89370 x/(x - 1)]
b = #[linear-fractional-transform 89335 (1 - x)]
c = #[linear-fractional-transform 89334 1/x]
```

Just as d3 permutes a triangle, these linear fractional transforms permute among the equivalence classes of cross ratios.