Average Error: 7.6 → 0.3
Time: 11.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.709880271411575334236640369265690195764 \cdot 10^{60} \lor \neg \left(y \le 7489437381217844503511040\right):\\ \;\;\;\;\frac{1}{\frac{1}{x + y} - \frac{\frac{y}{x + y}}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;y \le -2.709880271411575334236640369265690195764 \cdot 10^{60} \lor \neg \left(y \le 7489437381217844503511040\right):\\
\;\;\;\;\frac{1}{\frac{1}{x + y} - \frac{\frac{y}{x + y}}{z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

\end{array}
double f(double x, double y, double z) {
        double r514391 = x;
        double r514392 = y;
        double r514393 = r514391 + r514392;
        double r514394 = 1.0;
        double r514395 = z;
        double r514396 = r514392 / r514395;
        double r514397 = r514394 - r514396;
        double r514398 = r514393 / r514397;
        return r514398;
}

double f(double x, double y, double z) {
        double r514399 = y;
        double r514400 = -2.7098802714115753e+60;
        bool r514401 = r514399 <= r514400;
        double r514402 = 7.489437381217845e+24;
        bool r514403 = r514399 <= r514402;
        double r514404 = !r514403;
        bool r514405 = r514401 || r514404;
        double r514406 = 1.0;
        double r514407 = 1.0;
        double r514408 = x;
        double r514409 = r514408 + r514399;
        double r514410 = r514407 / r514409;
        double r514411 = r514399 / r514409;
        double r514412 = z;
        double r514413 = r514411 / r514412;
        double r514414 = r514410 - r514413;
        double r514415 = r514406 / r514414;
        double r514416 = r514399 / r514412;
        double r514417 = r514407 - r514416;
        double r514418 = r514409 / r514417;
        double r514419 = r514405 ? r514415 : r514418;
        return r514419;
}

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
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;y \lt -3.742931076268985646434612946949172132145 \cdot 10^{171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.553466245608673435460441960303815115662 \cdot 10^{168}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -2.7098802714115753e+60 or 7.489437381217845e+24 < y

    1. Initial program 17.2

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied clear-num17.3

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied div-sub17.3

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{x + y} - \frac{\frac{y}{z}}{x + y}}}\]
    6. Simplified0.2

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

    if -2.7098802714115753e+60 < y < 7.489437381217845e+24

    1. Initial program 0.3

      \[\frac{x + y}{1 - \frac{y}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.709880271411575334236640369265690195764 \cdot 10^{60} \lor \neg \left(y \le 7489437381217844503511040\right):\\ \;\;\;\;\frac{1}{\frac{1}{x + y} - \frac{\frac{y}{x + y}}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019350 
(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))))