Solution (source code)

= Solution

The displayed orthogonal <matrix> is a rotation through $2\alpha$, where $\sin^2\alpha=M/N$.