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 \left(\mathsf{fma}\left(2, x \cdot x, \mathsf{fma}\left(2, x, \log 1\right)\right) - 2 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\]
\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\frac{1}{2} \cdot \left(\mathsf{fma}\left(2, x \cdot x, \mathsf{fma}\left(2, x, \log 1\right)\right) - 2 \cdot \frac{{x}^{2}}{{1}^{2}}\right)
double f(double x) {
        double r56758 = 1.0;
        double r56759 = 2.0;
        double r56760 = r56758 / r56759;
        double r56761 = x;
        double r56762 = r56758 + r56761;
        double r56763 = r56758 - r56761;
        double r56764 = r56762 / r56763;
        double r56765 = log(r56764);
        double r56766 = r56760 * r56765;
        return r56766;
}

double f(double x) {
        double r56767 = 1.0;
        double r56768 = 2.0;
        double r56769 = r56767 / r56768;
        double r56770 = x;
        double r56771 = r56770 * r56770;
        double r56772 = log(r56767);
        double r56773 = fma(r56768, r56770, r56772);
        double r56774 = fma(r56768, r56771, r56773);
        double r56775 = 2.0;
        double r56776 = pow(r56770, r56775);
        double r56777 = pow(r56767, r56775);
        double r56778 = r56776 / r56777;
        double r56779 = r56768 * r56778;
        double r56780 = r56774 - r56779;
        double r56781 = r56769 * r56780;
        return r56781;
}

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}{\left(\mathsf{fma}\left(2, x \cdot x, \mathsf{fma}\left(2, x, \log 1\right)\right) - 2 \cdot \frac{{x}^{2}}{{1}^{2}}\right)}\]
  4. Final simplification0.6

    \[\leadsto \frac{1}{2} \cdot \left(\mathsf{fma}\left(2, x \cdot x, \mathsf{fma}\left(2, x, \log 1\right)\right) - 2 \cdot \frac{{x}^{2}}{{1}^{2}}\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)))))