Average Error: 58.6 → 0.6
Time: 14.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 r64252 = 1.0;
        double r64253 = 2.0;
        double r64254 = r64252 / r64253;
        double r64255 = x;
        double r64256 = r64252 + r64255;
        double r64257 = r64252 - r64255;
        double r64258 = r64256 / r64257;
        double r64259 = log(r64258);
        double r64260 = r64254 * r64259;
        return r64260;
}

double f(double x) {
        double r64261 = 1.0;
        double r64262 = 2.0;
        double r64263 = r64261 / r64262;
        double r64264 = x;
        double r64265 = r64261 * r64261;
        double r64266 = r64264 / r64265;
        double r64267 = r64264 - r64266;
        double r64268 = r64264 * r64267;
        double r64269 = log(r64261);
        double r64270 = fma(r64262, r64264, r64269);
        double r64271 = fma(r64262, r64268, r64270);
        double r64272 = r64263 * r64271;
        return r64272;
}

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)))))