TITLE: How to find $a+b$ in square $ABCD,$?
QUESTION [5 upvotes]: In square $ABCD,$ $AB=1.$ $BEFA$  and $MNOP$ are congruent. $BE= a - \sqrt b.$ Where $a$ and $b$ are both primes. How to find $a+b$? I have no idea how to do this, can this be proved with simple geometry?

REPLY [3 votes]: Let the side of the square be $p$ (so we can better track dimensions) and let $|\overline{BE}| = q$; and let $\theta = \angle EMP$. We have two equations:
$$\begin{align}
q + p \sin\theta + q \cos\theta &= p \\
p \cos\theta + q \sin\theta &= p
\end{align}$$
Solving for $\cos\theta$ and $\sin\theta$ gives
$$\cos\theta = \frac{p^2 - p q + q^2}{p^2 - q^2}\qquad \sin\theta = \frac{p\, (p - 2 q)}{p^2 - q^2}$$
Since $\sin^2\theta + \cos^2\theta = 1$, we deduce
$$\frac{p\,(p - 2 q)\,(p^2 - 4 p q + q^2)}{(p^2 - q^2)^2} = 0$$
so that $q = p/2$ (extraneous), or $q = p\,( 2 + \sqrt{ 3 } )$ (extraneous), or $q = p\,(2 - \sqrt{3})$ (bingo!).

Recalling $p=1$, we have $a = 2$ and $b = 3$, so that $a+b = 5$. $\square$

Note: In this solution, $\theta = 30^\circ$.