Average Error: 58.6 → 0.6
Time: 17.8s
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 r72005 = 1.0;
        double r72006 = 2.0;
        double r72007 = r72005 / r72006;
        double r72008 = x;
        double r72009 = r72005 + r72008;
        double r72010 = r72005 - r72008;
        double r72011 = r72009 / r72010;
        double r72012 = log(r72011);
        double r72013 = r72007 * r72012;
        return r72013;
}

double f(double x) {
        double r72014 = 1.0;
        double r72015 = 2.0;
        double r72016 = r72014 / r72015;
        double r72017 = x;
        double r72018 = r72014 * r72014;
        double r72019 = r72017 / r72018;
        double r72020 = r72017 - r72019;
        double r72021 = r72017 * r72020;
        double r72022 = log(r72014);
        double r72023 = fma(r72015, r72017, r72022);
        double r72024 = fma(r72015, r72021, r72023);
        double r72025 = r72016 * r72024;
        return r72025;
}

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