Average Error: 58.4 → 0.0
Time: 19.4s
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 r2632059 = 1.0;
        double r2632060 = 2.0;
        double r2632061 = r2632059 / r2632060;
        double r2632062 = x;
        double r2632063 = r2632059 + r2632062;
        double r2632064 = r2632059 - r2632062;
        double r2632065 = r2632063 / r2632064;
        double r2632066 = log(r2632065);
        double r2632067 = r2632061 * r2632066;
        return r2632067;
}

double f(double x) {
        double r2632068 = x;
        double r2632069 = log1p(r2632068);
        double r2632070 = -r2632068;
        double r2632071 = log1p(r2632070);
        double r2632072 = r2632069 - r2632071;
        double r2632073 = 0.5;
        double r2632074 = r2632072 * r2632073;
        return r2632074;
}

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}{\log \left(\frac{x + 1}{1 - x}\right) \cdot \frac{1}{2}}\]
  3. Using strategy rm
  4. Applied log-div58.4

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

    \[\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 sub-neg50.4

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

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