Average Error: 7.7 → 6.4
Time: 23.1s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -7.35087092213161045 \cdot 10^{-289} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{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 -7.35087092213161045 \cdot 10^{-289} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r473519 = x;
        double r473520 = y;
        double r473521 = r473519 + r473520;
        double r473522 = 1.0;
        double r473523 = z;
        double r473524 = r473520 / r473523;
        double r473525 = r473522 - r473524;
        double r473526 = r473521 / r473525;
        return r473526;
}

double f(double x, double y, double z) {
        double r473527 = x;
        double r473528 = y;
        double r473529 = r473527 + r473528;
        double r473530 = 1.0;
        double r473531 = z;
        double r473532 = r473528 / r473531;
        double r473533 = r473530 - r473532;
        double r473534 = r473529 / r473533;
        double r473535 = -7.35087092213161e-289;
        bool r473536 = r473534 <= r473535;
        double r473537 = -0.0;
        bool r473538 = r473534 <= r473537;
        double r473539 = !r473538;
        bool r473540 = r473536 || r473539;
        double r473541 = sqrt(r473530);
        double r473542 = sqrt(r473528);
        double r473543 = sqrt(r473531);
        double r473544 = r473542 / r473543;
        double r473545 = r473541 + r473544;
        double r473546 = r473529 / r473545;
        double r473547 = 1.0;
        double r473548 = r473541 - r473544;
        double r473549 = r473547 / r473548;
        double r473550 = r473546 * r473549;
        double r473551 = r473540 ? r473534 : r473550;
        return r473551;
}

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.7
Target4.3
Herbie6.4
\[\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))) < -7.35087092213161e-289 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.3

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

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

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

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

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

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

    if -7.35087092213161e-289 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 57.6

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

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

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

      \[\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-frac61.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-sqrt61.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-squares61.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 *-un-lft-identity61.1

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

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

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

      \[\leadsto \color{blue}{\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{1}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\]
  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 -7.35087092213161045 \cdot 10^{-289} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]

Reproduce

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

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

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