Does anyone know an equation relating wingspan to gliding distance for a glider?
Your mystery equation is
$$\text{Distance} = \text{Height}\cdot0.5\cdot\sqrt{\pi\cdot e\cdot\frac{b^2}{f}}$$
Since the flight distance is the product of the glide ratio (or lift-to-drag ratio) L/D and height, the equation can be written like this:
$$\frac{L}{D} = \frac{c_L}{c_D} = 0.5\cdot\sqrt{\pi\cdot e\cdot\frac{b^2}{f}}$$
if we use dimensionless coefficients instead of the dimensionful forces. Now that does look familiar, right? Only something seems to be missing. And that drag area $f$ should be the wing area.

Now you asked for the derivation, and I've done that only with wind in this answer, so let's do it for the simpler case of a glider and without wind right here. You start with the question: What polar point gives the best distance for a given height? Or, in other words, when does the lift-to-drag ratio reach its optimum? To get anywhere, you need a simple equation for the lift-to-drag ratio, so I recommend to start with the equation for the drag polar
$$D = \frac{\rho\cdot v^2}{2}\cdot S\cdot\left(c_{D0}+\frac{c_L^2}{\pi\cdot AR\cdot\epsilon}\right)$$
The terms inside the big bracket are the sum of the parasitic and the induced drag coefficient and the term in front of the bracket is the product of dynamic pressure and wing area. It is needed to turn the coefficients into a force. The symbols are:
$\kern{5mm} \rho\:\:\:\:\:$ air density
$\kern{5mm} v\:\:\:\:\:$ velocity
$\kern{5mm} S\:\:\:\:\:$ wing surface area
$\kern{5mm} c_{D0} \:$  zero-lift drag coefficient
$\kern{5mm} c_L \:\:\:$  lift coefficient
$\kern{5mm} \pi \:\:\:\:\:$  3.14159$\dots$
$\kern{5mm} AR \:\:$  aspect ratio of the wing
$\kern{5mm} \epsilon \:\:\:\:\:\:$  the wing's Oswald factor, normally between 0.8 and 1.0

Since lift should be constant over speed for a glider, the optimum lift-to-drag ratio is when drag reaches a minimum. We express the lift coefficient by what it stands for and differentiate drag with respect to speed:
$$D = \frac{\rho\cdot v^2}{2}\cdot S\cdot\ c_{D0}+\frac{(m\cdot g)^2}{\frac{\rho\cdot v^2}{2}\cdot S\cdot\pi\cdot AR\cdot\epsilon}$$
$$\Rightarrow\:\:\frac{dD}{dv} = \frac{2\cdot \rho\cdot v}{2}\cdot S\cdot c_{D0} - \frac{2}{v^3}\cdot\frac{2\cdot(m\cdot g)^2}{\rho\cdot S\cdot\pi\cdot AR\cdot\epsilon}$$

Drag should reach its minimum when the derivative equals zero. We try to isolate the zero lift drag by dividing the equation by all what is collected around it:
$$0 = c_{D0} - \frac{2}{v^4}\cdot\frac{2\cdot(m\cdot g)^2}{\rho^2\cdot S^2\cdot\pi\cdot AR\cdot\epsilon}$$
Now bring $c_{D0}$ to the other side and re-insert the lift coefficient. The result is:
$$c_{D0} = \frac{c_L^2}{\pi\cdot AR\cdot\epsilon}$$
This means that the optimum lift-to-drag ratio is reached when the zero-lift drag equals induced drag. Total drag is the sum of both and in this case equal to twice the induced drag. Written in coefficients, this is:
$$c_D = \frac{2\cdot c_L^2}{\pi\cdot AR\cdot\epsilon}$$
Written as the lift-to-drag ratio, this becomes:
$$\left(\frac{L}{D}\right)_{opt} = \frac{\pi\cdot AR\cdot\epsilon}{2\cdot c_L}$$
Since the optimum lift coefficient can be expressed as
$$c_{L_{opt}} = \sqrt{c_{D0}\cdot\pi\cdot AR\cdot\epsilon}$$
this can be inserted and the lift-to-drag ratio can be written as
$$\left(\frac{L}{D}\right)_{opt} = 0.5\cdot\sqrt{\frac{\pi\cdot AR\cdot\epsilon}{c_{D0}}}$$
The wing's aspect ratio is $AR = \frac{b^2}{S}$, and the mysterious drag surface must be $f = c_{D0}\cdot S$, and voilá, the strange equation is proven right. When the correct values are used, it is valid from mini paper airplanes up to Jumbo Jets and above. Airfoil drag is included in the zero-lift drag coefficient.