Average Error: 7.6 → 6.4
Time: 2.7s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -9.340220995992204435937211078763363155616 \cdot 10^{-288} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;{\left(\frac{x + y}{1 - \frac{y}{z}}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\frac{\sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\right)}^{1}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -9.340220995992204435937211078763363155616 \cdot 10^{-288} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\
\;\;\;\;{\left(\frac{x + y}{1 - \frac{y}{z}}\right)}^{1}\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\frac{\sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\right)}^{1}\\

\end{array}
double f(double x, double y, double z) {
        double r631390 = x;
        double r631391 = y;
        double r631392 = r631390 + r631391;
        double r631393 = 1.0;
        double r631394 = z;
        double r631395 = r631391 / r631394;
        double r631396 = r631393 - r631395;
        double r631397 = r631392 / r631396;
        return r631397;
}

double f(double x, double y, double z) {
        double r631398 = x;
        double r631399 = y;
        double r631400 = r631398 + r631399;
        double r631401 = 1.0;
        double r631402 = z;
        double r631403 = r631399 / r631402;
        double r631404 = r631401 - r631403;
        double r631405 = r631400 / r631404;
        double r631406 = -9.340220995992204e-288;
        bool r631407 = r631405 <= r631406;
        double r631408 = -0.0;
        bool r631409 = r631405 <= r631408;
        double r631410 = !r631409;
        bool r631411 = r631407 || r631410;
        double r631412 = 1.0;
        double r631413 = pow(r631405, r631412);
        double r631414 = sqrt(r631400);
        double r631415 = sqrt(r631401);
        double r631416 = sqrt(r631399);
        double r631417 = sqrt(r631402);
        double r631418 = r631416 / r631417;
        double r631419 = r631415 + r631418;
        double r631420 = r631414 / r631419;
        double r631421 = r631415 - r631418;
        double r631422 = r631421 / r631414;
        double r631423 = r631420 / r631422;
        double r631424 = pow(r631423, r631412);
        double r631425 = r631411 ? r631413 : r631424;
        return r631425;
}

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
Target3.9
Herbie6.4
\[\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 (/ (+ x y) (- 1.0 (/ y z))) < -9.340220995992204e-288 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.1

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

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

      \[\leadsto \left(x + y\right) \cdot \color{blue}{{\left(\frac{1}{1 - \frac{y}{z}}\right)}^{1}}\]
    6. Applied pow14.2

      \[\leadsto \color{blue}{{\left(x + y\right)}^{1}} \cdot {\left(\frac{1}{1 - \frac{y}{z}}\right)}^{1}\]
    7. Applied pow-prod-down4.2

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

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

    if -9.340220995992204e-288 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 57.3

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

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

      \[\leadsto \left(x + y\right) \cdot \color{blue}{{\left(\frac{1}{1 - \frac{y}{z}}\right)}^{1}}\]
    6. Applied pow157.3

      \[\leadsto \color{blue}{{\left(x + y\right)}^{1}} \cdot {\left(\frac{1}{1 - \frac{y}{z}}\right)}^{1}\]
    7. Applied pow-prod-down57.3

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

      \[\leadsto {\color{blue}{\left(\frac{x + y}{1 - \frac{y}{z}}\right)}}^{1}\]
    9. Using strategy rm
    10. Applied clear-num57.3

      \[\leadsto {\color{blue}{\left(\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}\right)}}^{1}\]
    11. Using strategy rm
    12. Applied add-sqr-sqrt60.9

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

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

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

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

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

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

      \[\leadsto {\left(\frac{1}{\color{blue}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}} \cdot \frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}}\right)}^{1}\]
    19. Applied associate-/r*35.5

      \[\leadsto {\color{blue}{\left(\frac{\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\right)}}^{1}\]
    20. Simplified35.4

      \[\leadsto {\left(\frac{\color{blue}{\frac{\sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\right)}^{1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.4

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

Reproduce

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