distance table derivation complete

The forms are ugly, but the table generation is in.