Average Error: 0.0 → 0.0
Time: 3.9s
Precision: 64
\[\frac{1}{x - 1} + \frac{x}{x + 1}\]
\[\log \left(\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{1}{x - 1}}\right)\right)\right) + \frac{x}{x + 1}\]
\frac{1}{x - 1} + \frac{x}{x + 1}
\log \left(\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{1}{x - 1}}\right)\right)\right) + \frac{x}{x + 1}
double f(double x) {
        double r123533 = 1.0;
        double r123534 = x;
        double r123535 = r123534 - r123533;
        double r123536 = r123533 / r123535;
        double r123537 = r123534 + r123533;
        double r123538 = r123534 / r123537;
        double r123539 = r123536 + r123538;
        return r123539;
}

double f(double x) {
        double r123540 = 1.0;
        double r123541 = x;
        double r123542 = r123541 - r123540;
        double r123543 = r123540 / r123542;
        double r123544 = exp(r123543);
        double r123545 = log1p(r123544);
        double r123546 = expm1(r123545);
        double r123547 = log(r123546);
        double r123548 = r123541 + r123540;
        double r123549 = r123541 / r123548;
        double r123550 = r123547 + r123549;
        return r123550;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\frac{1}{x - 1} + \frac{x}{x + 1}\]
  2. Using strategy rm
  3. Applied add-log-exp0.0

    \[\leadsto \color{blue}{\log \left(e^{\frac{1}{x - 1}}\right)} + \frac{x}{x + 1}\]
  4. Using strategy rm
  5. Applied expm1-log1p-u0.0

    \[\leadsto \log \color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{1}{x - 1}}\right)\right)\right)} + \frac{x}{x + 1}\]
  6. Final simplification0.0

    \[\leadsto \log \left(\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{1}{x - 1}}\right)\right)\right) + \frac{x}{x + 1}\]

Reproduce

herbie shell --seed 2020039 +o rules:numerics
(FPCore (x)
  :name "Asymptote B"
  :precision binary64
  (+ (/ 1 (- x 1)) (/ x (+ x 1))))