Average Error: 7.6 → 7.6
Time: 11.6s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\frac{x + y}{1 - \frac{y}{z}}\]
\frac{x + y}{1 - \frac{y}{z}}
\frac{x + y}{1 - \frac{y}{z}}
double f(double x, double y, double z) {
        double r766017 = x;
        double r766018 = y;
        double r766019 = r766017 + r766018;
        double r766020 = 1.0;
        double r766021 = z;
        double r766022 = r766018 / r766021;
        double r766023 = r766020 - r766022;
        double r766024 = r766019 / r766023;
        return r766024;
}

double f(double x, double y, double z) {
        double r766025 = x;
        double r766026 = y;
        double r766027 = r766025 + r766026;
        double r766028 = 1.0;
        double r766029 = z;
        double r766030 = r766026 / r766029;
        double r766031 = r766028 - r766030;
        double r766032 = r766027 / r766031;
        return r766032;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.6
Target4.0
Herbie7.6
\[\begin{array}{l} \mathbf{if}\;y \lt -3.74293107626898565 \cdot 10^{171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.55346624560867344 \cdot 10^{168}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \end{array}\]

Derivation

  1. Initial program 7.6

    \[\frac{x + y}{1 - \frac{y}{z}}\]
  2. Final simplification7.6

    \[\leadsto \frac{x + y}{1 - \frac{y}{z}}\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :herbie-target
  (if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))

  (/ (+ x y) (- 1 (/ y z))))