Average Error: 58.5 → 0.7
Time: 17.4s
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 r52626 = 1.0;
        double r52627 = 2.0;
        double r52628 = r52626 / r52627;
        double r52629 = x;
        double r52630 = r52626 + r52629;
        double r52631 = r52626 - r52629;
        double r52632 = r52630 / r52631;
        double r52633 = log(r52632);
        double r52634 = r52628 * r52633;
        return r52634;
}

double f(double x) {
        double r52635 = 1.0;
        double r52636 = 2.0;
        double r52637 = r52635 / r52636;
        double r52638 = x;
        double r52639 = r52635 * r52635;
        double r52640 = r52638 / r52639;
        double r52641 = r52638 - r52640;
        double r52642 = r52638 * r52641;
        double r52643 = log(r52635);
        double r52644 = fma(r52636, r52638, r52643);
        double r52645 = fma(r52636, r52642, r52644);
        double r52646 = r52637 * r52645;
        return r52646;
}

Error

Bits error versus x

Derivation

  1. Initial program 58.5

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

    \[\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.7

    \[\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.7

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