Average Error: 14.5 → 0.1
Time: 11.9s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x + 1}}{x - 1}\right)\right) \cdot -2\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x + 1}}{x - 1}\right)\right) \cdot -2
double f(double x) {
        double r2542147 = 1.0;
        double r2542148 = x;
        double r2542149 = r2542148 + r2542147;
        double r2542150 = r2542147 / r2542149;
        double r2542151 = r2542148 - r2542147;
        double r2542152 = r2542147 / r2542151;
        double r2542153 = r2542150 - r2542152;
        return r2542153;
}

double f(double x) {
        double r2542154 = 1.0;
        double r2542155 = x;
        double r2542156 = r2542155 + r2542154;
        double r2542157 = r2542154 / r2542156;
        double r2542158 = r2542155 - r2542154;
        double r2542159 = r2542157 / r2542158;
        double r2542160 = expm1(r2542159);
        double r2542161 = log1p(r2542160);
        double r2542162 = -2.0;
        double r2542163 = r2542161 * r2542162;
        return r2542163;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.5

    \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
  2. Using strategy rm
  3. Applied flip--29.3

    \[\leadsto \frac{1}{x + 1} - \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
  4. Applied associate-/r/29.3

    \[\leadsto \frac{1}{x + 1} - \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)}\]
  5. Applied flip-+14.5

    \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
  6. Applied associate-/r/14.5

    \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
  7. Applied distribute-lft-out--13.8

    \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)}\]
  8. Taylor expanded around 0 0.4

    \[\leadsto \frac{1}{x \cdot x - 1 \cdot 1} \cdot \color{blue}{-2}\]
  9. Using strategy rm
  10. Applied difference-of-squares0.4

    \[\leadsto \frac{1}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \cdot -2\]
  11. Applied associate-/r*0.1

    \[\leadsto \color{blue}{\frac{\frac{1}{x + 1}}{x - 1}} \cdot -2\]
  12. Using strategy rm
  13. Applied log1p-expm1-u0.1

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

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

Reproduce

herbie shell --seed 2019155 +o rules:numerics
(FPCore (x)
  :name "Asymptote A"
  (- (/ 1 (+ x 1)) (/ 1 (- x 1))))