Average Error: 58.6 → 0.6
Time: 10.1s
Precision: 64
\[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)\]
\[\frac{1}{2} \cdot \mathsf{fma}\left(2, x \cdot \left(x - \frac{x}{1 \cdot 1}\right), \mathsf{fma}\left(2, x, \log 1\right)\right)\]
\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\frac{1}{2} \cdot \mathsf{fma}\left(2, x \cdot \left(x - \frac{x}{1 \cdot 1}\right), \mathsf{fma}\left(2, x, \log 1\right)\right)
double f(double x) {
        double r53595 = 1.0;
        double r53596 = 2.0;
        double r53597 = r53595 / r53596;
        double r53598 = x;
        double r53599 = r53595 + r53598;
        double r53600 = r53595 - r53598;
        double r53601 = r53599 / r53600;
        double r53602 = log(r53601);
        double r53603 = r53597 * r53602;
        return r53603;
}

double f(double x) {
        double r53604 = 1.0;
        double r53605 = 2.0;
        double r53606 = r53604 / r53605;
        double r53607 = x;
        double r53608 = r53604 * r53604;
        double r53609 = r53607 / r53608;
        double r53610 = r53607 - r53609;
        double r53611 = r53607 * r53610;
        double r53612 = log(r53604);
        double r53613 = fma(r53605, r53607, r53612);
        double r53614 = fma(r53605, r53611, r53613);
        double r53615 = r53606 * r53614;
        return r53615;
}

Error

Bits error versus x

Derivation

  1. Initial program 58.6

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)\]
  2. Taylor expanded around 0 0.6

    \[\leadsto \frac{1}{2} \cdot \color{blue}{\left(\left(2 \cdot {x}^{2} + \left(2 \cdot x + \log 1\right)\right) - 2 \cdot \frac{{x}^{2}}{{1}^{2}}\right)}\]
  3. Simplified0.6

    \[\leadsto \frac{1}{2} \cdot \color{blue}{\mathsf{fma}\left(2, x \cdot \left(x - \frac{x}{1 \cdot 1}\right), \mathsf{fma}\left(2, x, \log 1\right)\right)}\]
  4. Final simplification0.6

    \[\leadsto \frac{1}{2} \cdot \mathsf{fma}\left(2, x \cdot \left(x - \frac{x}{1 \cdot 1}\right), \mathsf{fma}\left(2, x, \log 1\right)\right)\]

Reproduce

herbie shell --seed 2019351 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-(co)tangent"
  :precision binary64
  (* (/ 1 2) (log (/ (+ 1 x) (- 1 x)))))