5. As shown in Figure 2, $\triangle A E F$ is an inscribed triangle in the square $A B C D$ with side length $x$. If $\angle A E F=90^{\circ}$, $A E=a, E F=b(a>b)$, then $x=$
5. $\frac{a^{2}}{\sqrt{a^{2}+(a-b)^{2}}}$.

Let $\angle A E B=\theta$ ( $\theta$ is an acute angle). Then $a \cos \theta+b \sin \theta=x=a \sin \theta$.
Thus $(a-b) \sin \theta=a \cos \theta$
$\Rightarrow \tan \theta=\frac{a}{a-b}$
$\Rightarrow \sin \theta=\frac{a}{\sqrt{a^{2}+(a-b)^{2}}}$.
Therefore, $x=a \sin \theta=\frac{a^{2}}{\sqrt{a^{2}+(a-b)^{2}}}$.