Average Error: 58.6 → 0.0
Time: 20.8s
Precision: 64
\[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)\]
\[\frac{\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)}{2}\]
\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\frac{\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)}{2}
double f(double x) {
        double r2051927 = 1.0;
        double r2051928 = 2.0;
        double r2051929 = r2051927 / r2051928;
        double r2051930 = x;
        double r2051931 = r2051927 + r2051930;
        double r2051932 = r2051927 - r2051930;
        double r2051933 = r2051931 / r2051932;
        double r2051934 = log(r2051933);
        double r2051935 = r2051929 * r2051934;
        return r2051935;
}

double f(double x) {
        double r2051936 = x;
        double r2051937 = log1p(r2051936);
        double r2051938 = -r2051936;
        double r2051939 = log1p(r2051938);
        double r2051940 = r2051937 - r2051939;
        double r2051941 = 2.0;
        double r2051942 = r2051940 / r2051941;
        return r2051942;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.6

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)\]
  2. Simplified58.6

    \[\leadsto \color{blue}{\frac{\log \left(\frac{x + 1}{1 - x}\right)}{2}}\]
  3. Using strategy rm
  4. Applied log-div58.6

    \[\leadsto \frac{\color{blue}{\log \left(x + 1\right) - \log \left(1 - x\right)}}{2}\]
  5. Simplified50.5

    \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)}{2}\]
  6. Using strategy rm
  7. Applied log1p-expm1-u50.5

    \[\leadsto \frac{\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(1 - x\right)\right)\right)}}{2}\]
  8. Simplified0.0

    \[\leadsto \frac{\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(\color{blue}{-x}\right)}{2}\]
  9. Final simplification0.0

    \[\leadsto \frac{\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)}{2}\]

Reproduce

herbie shell --seed 2019134 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-(co)tangent"
  (* (/ 1 2) (log (/ (+ 1 x) (- 1 x)))))