Average Error: 58.4 → 0.0
Time: 15.8s
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 r1415877 = 1.0;
        double r1415878 = 2.0;
        double r1415879 = r1415877 / r1415878;
        double r1415880 = x;
        double r1415881 = r1415877 + r1415880;
        double r1415882 = r1415877 - r1415880;
        double r1415883 = r1415881 / r1415882;
        double r1415884 = log(r1415883);
        double r1415885 = r1415879 * r1415884;
        return r1415885;
}

double f(double x) {
        double r1415886 = x;
        double r1415887 = log1p(r1415886);
        double r1415888 = -r1415886;
        double r1415889 = log1p(r1415888);
        double r1415890 = r1415887 - r1415889;
        double r1415891 = 0.5;
        double r1415892 = r1415890 * r1415891;
        return r1415892;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.4

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

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

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

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

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

    \[\leadsto \frac{1}{2} \cdot \left(\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(-x\right)}\right)\]
  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 2019151 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-(co)tangent"
  (* (/ 1 2) (log (/ (+ 1 x) (- 1 x)))))