Average Error: 58.5 → 0.7
Time: 16.7s
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 r55803 = 1.0;
        double r55804 = 2.0;
        double r55805 = r55803 / r55804;
        double r55806 = x;
        double r55807 = r55803 + r55806;
        double r55808 = r55803 - r55806;
        double r55809 = r55807 / r55808;
        double r55810 = log(r55809);
        double r55811 = r55805 * r55810;
        return r55811;
}

double f(double x) {
        double r55812 = 1.0;
        double r55813 = 2.0;
        double r55814 = r55812 / r55813;
        double r55815 = x;
        double r55816 = r55812 * r55812;
        double r55817 = r55815 / r55816;
        double r55818 = r55815 - r55817;
        double r55819 = r55815 * r55818;
        double r55820 = log(r55812);
        double r55821 = fma(r55813, r55815, r55820);
        double r55822 = fma(r55813, r55819, r55821);
        double r55823 = r55814 * r55822;
        return r55823;
}

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