Average Error: 0.0 → 0.9
Time: 3.2s
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 r765688 = x;
        double r765689 = y;
        double r765690 = r765688 - r765689;
        double r765691 = r765688 + r765689;
        double r765692 = r765690 / r765691;
        return r765692;
}

double f(double x, double y) {
        double r765693 = x;
        double r765694 = y;
        double r765695 = r765693 - r765694;
        double r765696 = r765693 + r765694;
        double r765697 = r765695 / r765696;
        double r765698 = log1p(r765697);
        double r765699 = expm1(r765698);
        double r765700 = exp(r765699);
        double r765701 = log(r765700);
        return r765701;
}

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)))