Average Error: 58.7 → 0.6
Time: 10.6s
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 r52552 = 1.0;
        double r52553 = 2.0;
        double r52554 = r52552 / r52553;
        double r52555 = x;
        double r52556 = r52552 + r52555;
        double r52557 = r52552 - r52555;
        double r52558 = r52556 / r52557;
        double r52559 = log(r52558);
        double r52560 = r52554 * r52559;
        return r52560;
}

double f(double x) {
        double r52561 = 1.0;
        double r52562 = 2.0;
        double r52563 = r52561 / r52562;
        double r52564 = x;
        double r52565 = r52561 * r52561;
        double r52566 = r52564 / r52565;
        double r52567 = r52564 - r52566;
        double r52568 = r52564 * r52567;
        double r52569 = log(r52561);
        double r52570 = fma(r52562, r52564, r52569);
        double r52571 = fma(r52562, r52568, r52570);
        double r52572 = r52563 * r52571;
        return r52572;
}

Error

Bits error versus x

Derivation

  1. Initial program 58.7

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