Average Error: 58.6 → 0.6
Time: 17.2s
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 r44670 = 1.0;
        double r44671 = 2.0;
        double r44672 = r44670 / r44671;
        double r44673 = x;
        double r44674 = r44670 + r44673;
        double r44675 = r44670 - r44673;
        double r44676 = r44674 / r44675;
        double r44677 = log(r44676);
        double r44678 = r44672 * r44677;
        return r44678;
}

double f(double x) {
        double r44679 = 1.0;
        double r44680 = 2.0;
        double r44681 = r44679 / r44680;
        double r44682 = x;
        double r44683 = r44679 * r44679;
        double r44684 = r44682 / r44683;
        double r44685 = r44682 - r44684;
        double r44686 = r44682 * r44685;
        double r44687 = log(r44679);
        double r44688 = fma(r44680, r44682, r44687);
        double r44689 = fma(r44680, r44686, r44688);
        double r44690 = r44681 * r44689;
        return r44690;
}

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 2019323 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-(co)tangent"
  :precision binary64
  (* (/ 1 2) (log (/ (+ 1 x) (- 1 x)))))