Average Error: 58.7 → 0.0
Time: 13.5s
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 r1246546 = 1.0;
        double r1246547 = 2.0;
        double r1246548 = r1246546 / r1246547;
        double r1246549 = x;
        double r1246550 = r1246546 + r1246549;
        double r1246551 = r1246546 - r1246549;
        double r1246552 = r1246550 / r1246551;
        double r1246553 = log(r1246552);
        double r1246554 = r1246548 * r1246553;
        return r1246554;
}

double f(double x) {
        double r1246555 = x;
        double r1246556 = log1p(r1246555);
        double r1246557 = -r1246555;
        double r1246558 = log1p(r1246557);
        double r1246559 = r1246556 - r1246558;
        double r1246560 = 0.5;
        double r1246561 = r1246559 * r1246560;
        return r1246561;
}

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

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

    \[\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.6

    \[\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 2019152 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-(co)tangent"
  (* (/ 1 2) (log (/ (+ 1 x) (- 1 x)))))