31 If $x, y, z>0$, and $x^{2}+y^{2}+z^{2}=1$, then $S=\frac{(z+1)^{2}}{2 x y z}$ reaches its minimum value when $x$ equals
$31 \sqrt{\sqrt{2}-1}$.
$$
S \geqslant \frac{(z+1)^{2}}{\left(x^{2}+y^{2}\right) z}=\frac{(z+1)^{2}}{\left(1-z^{2}\right) z}=\frac{z+1}{(1-z) z} .
$$

Let $u=\frac{z+1}{(1-z) z}, 0<z<1$ and
$$
u z^{2}+(1-u) z+1=0
$$

has real roots, so
$$
(1-u)^{2} \geqslant 4 u
$$

which means $u^{2}-6 u+1 \geqslant 0$
thus $u \geqslant 3+2 \sqrt{2}$.
When $z^{2}=\frac{3+2 \sqrt{2}-1}{2(3+2 \sqrt{2})}=\sqrt{2}-1$, $u=\frac{z+1}{(1-z) z}$ reaches its minimum value $3+2 \sqrt{2}$. Therefore, when $S$ reaches its minimum value,
$$
x=\sqrt{\frac{1-(\sqrt{2}-1)^{2}}{2}}=\sqrt{\sqrt{2}-1} .
$$