Average Error: 8.1 → 6.5
Time: 14.7s
Precision: 64
\[\frac{x + y}{1.0 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -2.713922652192976 \cdot 10^{-295}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{y + x}} \cdot \frac{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{y + x}}}\\ \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 -2.713922652192976 \cdot 10^{-295}:\\
\;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r27190124 = x;
        double r27190125 = y;
        double r27190126 = r27190124 + r27190125;
        double r27190127 = 1.0;
        double r27190128 = z;
        double r27190129 = r27190125 / r27190128;
        double r27190130 = r27190127 - r27190129;
        double r27190131 = r27190126 / r27190130;
        return r27190131;
}

double f(double x, double y, double z) {
        double r27190132 = y;
        double r27190133 = x;
        double r27190134 = r27190132 + r27190133;
        double r27190135 = 1.0;
        double r27190136 = z;
        double r27190137 = r27190132 / r27190136;
        double r27190138 = r27190135 - r27190137;
        double r27190139 = r27190134 / r27190138;
        double r27190140 = -2.713922652192976e-295;
        bool r27190141 = r27190139 <= r27190140;
        double r27190142 = -0.0;
        bool r27190143 = r27190139 <= r27190142;
        double r27190144 = 1.0;
        double r27190145 = sqrt(r27190135);
        double r27190146 = sqrt(r27190132);
        double r27190147 = sqrt(r27190136);
        double r27190148 = r27190146 / r27190147;
        double r27190149 = r27190145 - r27190148;
        double r27190150 = sqrt(r27190134);
        double r27190151 = r27190149 / r27190150;
        double r27190152 = r27190145 + r27190148;
        double r27190153 = r27190152 / r27190150;
        double r27190154 = r27190151 * r27190153;
        double r27190155 = r27190144 / r27190154;
        double r27190156 = r27190143 ? r27190155 : r27190139;
        double r27190157 = r27190141 ? r27190139 : r27190156;
        return r27190157;
}

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.1
Target4.5
Herbie6.5
\[\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))) < -2.713922652192976e-295 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -2.713922652192976e-295 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 59.6

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1.0 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt61.4

      \[\leadsto \frac{1}{\frac{1.0 - \frac{y}{z}}{\color{blue}{\sqrt{x + y} \cdot \sqrt{x + y}}}}\]
    6. Applied add-sqr-sqrt62.0

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

      \[\leadsto \frac{1}{\frac{1.0 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}{\sqrt{x + y} \cdot \sqrt{x + y}}}\]
    8. Applied times-frac62.0

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

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

      \[\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)}}{\sqrt{x + y} \cdot \sqrt{x + y}}}\]
    11. Applied times-frac48.1

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

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

Reproduce

herbie shell --seed 2019168 +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))))