Average Error: 58.6 → 0.6
Time: 18.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 r52166 = 1.0;
        double r52167 = 2.0;
        double r52168 = r52166 / r52167;
        double r52169 = x;
        double r52170 = r52166 + r52169;
        double r52171 = r52166 - r52169;
        double r52172 = r52170 / r52171;
        double r52173 = log(r52172);
        double r52174 = r52168 * r52173;
        return r52174;
}

double f(double x) {
        double r52175 = 1.0;
        double r52176 = 2.0;
        double r52177 = r52175 / r52176;
        double r52178 = x;
        double r52179 = r52175 * r52175;
        double r52180 = r52178 / r52179;
        double r52181 = r52178 - r52180;
        double r52182 = r52178 * r52181;
        double r52183 = log(r52175);
        double r52184 = fma(r52176, r52178, r52183);
        double r52185 = fma(r52176, r52182, r52184);
        double r52186 = r52177 * r52185;
        return r52186;
}

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