The side of the base of a regular quadrilateral pyramid is equal to $a$, and the lateral edge is equal to $b$. Find the radius of the sphere that touches all the edges of the pyramid.
Let $PM$ be the height of the regular quadrilateral pyramid $PABCD$, and $r$ be the desired radius. Since the pyramid is regular, the center $Q$ of the sphere that touches all the edges of the pyramid lies on the line $PM$, and the points of tangency of the sphere with the sides of the base coincide with the midpoints of these sides. If $K$ and $L$ are the points of tangency of the sphere with the edges $AB$ and $AP$ respectively, then

$$
QL \perp AP, \quad AK = \frac{a}{2}, \quad PL = AP - AL = b - \frac{a}{2} = \frac{2b - a}{2}.
$$

From the right triangle $AMP$, we find that

$$
PM = \sqrt{AP^2 - AM^2} = \sqrt{b^2 - \left(\frac{a}{\sqrt{2}}\right)^2} = \frac{\sqrt{22^2 - a^2}}{\sqrt{2}}.
$$

From the similarity of the right triangles $PLQ$ and $PMA$, it follows that

$$
\frac{QL}{PL} = \frac{AM}{PM}.
$$

Thus,

$$
r = QL = PL \cdot \frac{AM}{PM} = \frac{2b - a}{2} \cdot \frac{\frac{a}{\sqrt{2}}}{\sqrt{2b^2 - a^2}} = \frac{(2b - a)}{2 \sqrt{2b^2 - a^2}}.
$$

## Answer

$\frac{(2b - a)}{2 \sqrt{2b^2 - a^2}}$