Average Error: 58.6 → 0.6
Time: 17.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 r60798 = 1.0;
        double r60799 = 2.0;
        double r60800 = r60798 / r60799;
        double r60801 = x;
        double r60802 = r60798 + r60801;
        double r60803 = r60798 - r60801;
        double r60804 = r60802 / r60803;
        double r60805 = log(r60804);
        double r60806 = r60800 * r60805;
        return r60806;
}

double f(double x) {
        double r60807 = 1.0;
        double r60808 = 2.0;
        double r60809 = r60807 / r60808;
        double r60810 = x;
        double r60811 = r60807 * r60807;
        double r60812 = r60810 / r60811;
        double r60813 = r60810 - r60812;
        double r60814 = r60810 * r60813;
        double r60815 = log(r60807);
        double r60816 = fma(r60808, r60810, r60815);
        double r60817 = fma(r60808, r60814, r60816);
        double r60818 = r60809 * r60817;
        return r60818;
}

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