Demystifying the Beigel-Reingold-Spielman construction

The hyperbolic tangent

$$\tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$

Often, this function is used as a smooth approximation for the sign function.

Trying the same with truncated exponentials

Doesn't quite work :-(

Why doesn't it work?

$$ \begin{align*} \operatorname{tanh-proxy}(f,x) &= \frac{f(x) - f(-x)}{f(x) + f(-x)}\\ & = \frac{f(x) + f(-x)}{f(x) + f(-x)} - \frac{2f(-x)}{f(x) + f(-x)}\\ & = 1 + \frac{2}{\left(\frac{f(x)}{-f(-x)}\right) - 1} \end{align*} $$

If we can somehow ensure that $f(x) > 10 \cdot (- f(-x)) > 0$ for all $x > 0$, then we will have that $1 \leq\operatorname{tanh-proxy}(f,x) \leq 1.22..$ for all $x > 0$.

One issue is that, for any odd-degree polynomial, for large enough $x$ we will always have $f(x) \approx -f(-x)$. Therefore, $\operatorname{tanh-proxy}(f,x)$ shoots to $\infty$ as $x$ grows. Similarly, if $f$ is an even-degree polynomial, then $f(x) \approx f(-x)$ for large $x$ and this means that $\operatorname{tanh-proxy}(f,x)$ goes to $0$ in this case as $x$ grows.

If we wish to somehow ensure that $f(x) > 10 \cdot (- f(-x))$, we want to choose an odd-degree polynomial f, and also figure out a way to keep giving some advantage to the positive side, at least until $x \leq 2^n$.

The Beigel-Reingold-Spielman function

$$ \begin{align*} \operatorname{BRS}_n(x) &= (x+1) \prod_{i=1}^n (x + 2^i)^2\\ \operatorname{BRS-tanh}_n(x) &= \frac{\operatorname{BRS}_n(x)-\operatorname{BRS}_n(-x)}{\operatorname{BRS}_n(x)+\operatorname{BRS}_n(-x)} \end{align*} $$

That's awesome!

Reference: "PP is closed under intersection" by Richard Beigel, Nick Reingold and Daniel Spielman