Average Error: 58.6 → 0.6
Time: 16.3s
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 r53892 = 1.0;
        double r53893 = 2.0;
        double r53894 = r53892 / r53893;
        double r53895 = x;
        double r53896 = r53892 + r53895;
        double r53897 = r53892 - r53895;
        double r53898 = r53896 / r53897;
        double r53899 = log(r53898);
        double r53900 = r53894 * r53899;
        return r53900;
}

double f(double x) {
        double r53901 = 1.0;
        double r53902 = 2.0;
        double r53903 = r53901 / r53902;
        double r53904 = x;
        double r53905 = r53901 * r53901;
        double r53906 = r53904 / r53905;
        double r53907 = r53904 - r53906;
        double r53908 = r53904 * r53907;
        double r53909 = log(r53901);
        double r53910 = fma(r53902, r53904, r53909);
        double r53911 = fma(r53902, r53908, r53910);
        double r53912 = r53903 * r53911;
        return r53912;
}

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