Average Error: 58.7 → 0.0
Time: 19.2s
Precision: 64
\[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)\]
\[\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2}\]
\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2}
double f(double x) {
        double r2144043 = 1.0;
        double r2144044 = 2.0;
        double r2144045 = r2144043 / r2144044;
        double r2144046 = x;
        double r2144047 = r2144043 + r2144046;
        double r2144048 = r2144043 - r2144046;
        double r2144049 = r2144047 / r2144048;
        double r2144050 = log(r2144049);
        double r2144051 = r2144045 * r2144050;
        return r2144051;
}

double f(double x) {
        double r2144052 = x;
        double r2144053 = log1p(r2144052);
        double r2144054 = -r2144052;
        double r2144055 = log1p(r2144054);
        double r2144056 = r2144053 - r2144055;
        double r2144057 = 0.5;
        double r2144058 = r2144056 * r2144057;
        return r2144058;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.7

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

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

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

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

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

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

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

Reproduce

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