Average Error: 7.7 → 6.2
Time: 34.0s
Precision: 64
\[\frac{x + y}{1.0 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -5.127395520009548 \cdot 10^{-284}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\ \;\;\;\;\frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{y + x}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1.0 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -5.127395520009548 \cdot 10^{-284}:\\
\;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\

\mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\
\;\;\;\;\frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{y + x}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r31527669 = x;
        double r31527670 = y;
        double r31527671 = r31527669 + r31527670;
        double r31527672 = 1.0;
        double r31527673 = z;
        double r31527674 = r31527670 / r31527673;
        double r31527675 = r31527672 - r31527674;
        double r31527676 = r31527671 / r31527675;
        return r31527676;
}

double f(double x, double y, double z) {
        double r31527677 = y;
        double r31527678 = x;
        double r31527679 = r31527677 + r31527678;
        double r31527680 = 1.0;
        double r31527681 = z;
        double r31527682 = r31527677 / r31527681;
        double r31527683 = r31527680 - r31527682;
        double r31527684 = r31527679 / r31527683;
        double r31527685 = -5.127395520009548e-284;
        bool r31527686 = r31527684 <= r31527685;
        double r31527687 = -0.0;
        bool r31527688 = r31527684 <= r31527687;
        double r31527689 = 1.0;
        double r31527690 = sqrt(r31527680);
        double r31527691 = sqrt(r31527677);
        double r31527692 = sqrt(r31527681);
        double r31527693 = r31527691 / r31527692;
        double r31527694 = r31527690 + r31527693;
        double r31527695 = r31527689 / r31527694;
        double r31527696 = r31527690 - r31527693;
        double r31527697 = r31527679 / r31527696;
        double r31527698 = r31527695 * r31527697;
        double r31527699 = r31527688 ? r31527698 : r31527684;
        double r31527700 = r31527686 ? r31527684 : r31527699;
        return r31527700;
}

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.4
Herbie6.2
\[\begin{array}{l} \mathbf{if}\;y \lt -3.7429310762689856 \cdot 10^{+171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.5534662456086734 \cdot 10^{+168}:\\ \;\;\;\;\frac{x + y}{1.0 - \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))) < -5.127395520009548e-284 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

      \[\frac{x + y}{1.0 - \frac{y}{z}}\]

    if -5.127395520009548e-284 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 58.6

      \[\frac{x + y}{1.0 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied clear-num58.6

      \[\leadsto \color{blue}{\frac{1}{\frac{1.0 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity58.6

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}{1} \cdot \frac{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}}\]
    12. Applied add-cube-cbrt47.2

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}}\]
    14. Simplified47.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\]
    15. Simplified47.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -5.127395520009548 \cdot 10^{-284}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\ \;\;\;\;\frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{y + x}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \end{array}\]

Reproduce

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