Average Error: 0.0 → 0.9
Time: 3.1s
Precision: 64
\[\frac{x - y}{x + y}\]
\[\log \left(e^{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - y}{x + y}\right)\right)}\right)\]
\frac{x - y}{x + y}
\log \left(e^{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - y}{x + y}\right)\right)}\right)
double f(double x, double y) {
        double r889183 = x;
        double r889184 = y;
        double r889185 = r889183 - r889184;
        double r889186 = r889183 + r889184;
        double r889187 = r889185 / r889186;
        return r889187;
}

double f(double x, double y) {
        double r889188 = x;
        double r889189 = y;
        double r889190 = r889188 - r889189;
        double r889191 = r889188 + r889189;
        double r889192 = r889190 / r889191;
        double r889193 = log1p(r889192);
        double r889194 = expm1(r889193);
        double r889195 = exp(r889194);
        double r889196 = log(r889195);
        return r889196;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.9
\[\frac{x}{x + y} - \frac{y}{x + y}\]

Derivation

  1. Initial program 0.0

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

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

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

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

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, D"
  :precision binary64

  :herbie-target
  (- (/ x (+ x y)) (/ y (+ x y)))

  (/ (- x y) (+ x y)))