Average Error: 8.0 → 6.6
Time: 4.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -6.40202464514393151 \cdot 10^{-308} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -6.40202464514393151 \cdot 10^{-308} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\
\;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\

\end{array}
double f(double x, double y, double z) {
        double r603438 = x;
        double r603439 = y;
        double r603440 = r603438 + r603439;
        double r603441 = 1.0;
        double r603442 = z;
        double r603443 = r603439 / r603442;
        double r603444 = r603441 - r603443;
        double r603445 = r603440 / r603444;
        return r603445;
}

double f(double x, double y, double z) {
        double r603446 = x;
        double r603447 = y;
        double r603448 = r603446 + r603447;
        double r603449 = 1.0;
        double r603450 = z;
        double r603451 = r603447 / r603450;
        double r603452 = r603449 - r603451;
        double r603453 = r603448 / r603452;
        double r603454 = -6.402024645143932e-308;
        bool r603455 = r603453 <= r603454;
        double r603456 = -0.0;
        bool r603457 = r603453 <= r603456;
        double r603458 = !r603457;
        bool r603459 = r603455 || r603458;
        double r603460 = 1.0;
        double r603461 = r603460 / r603452;
        double r603462 = r603448 * r603461;
        double r603463 = sqrt(r603449);
        double r603464 = sqrt(r603447);
        double r603465 = sqrt(r603450);
        double r603466 = r603464 / r603465;
        double r603467 = r603463 + r603466;
        double r603468 = r603448 / r603467;
        double r603469 = cbrt(r603460);
        double r603470 = r603463 - r603466;
        double r603471 = r603469 / r603470;
        double r603472 = r603468 * r603471;
        double r603473 = r603459 ? r603462 : r603472;
        return r603473;
}

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

Original8.0
Target3.9
Herbie6.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. Split input into 2 regimes
  2. if (/ (+ x y) (- 1.0 (/ y z))) < -6.402024645143932e-308 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}}\]

    if -6.402024645143932e-308 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 60.1

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

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt62.2

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\]
    6. Applied add-sqr-sqrt63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    7. Applied times-frac63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    8. Applied add-sqr-sqrt63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    9. Applied difference-of-squares63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    10. Applied add-cube-cbrt63.1

      \[\leadsto \left(x + y\right) \cdot \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}\]
    11. Applied times-frac62.3

      \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\right)}\]
    12. Applied associate-*r*48.8

      \[\leadsto \color{blue}{\left(\left(x + y\right) \cdot \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}\right) \cdot \frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}\]
    13. Simplified48.8

      \[\leadsto \color{blue}{\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.6

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

Reproduce

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