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

\mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\
\;\;\;\;\frac{y + x}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\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 r24349171 = x;
        double r24349172 = y;
        double r24349173 = r24349171 + r24349172;
        double r24349174 = 1.0;
        double r24349175 = z;
        double r24349176 = r24349172 / r24349175;
        double r24349177 = r24349174 - r24349176;
        double r24349178 = r24349173 / r24349177;
        return r24349178;
}

double f(double x, double y, double z) {
        double r24349179 = y;
        double r24349180 = x;
        double r24349181 = r24349179 + r24349180;
        double r24349182 = 1.0;
        double r24349183 = z;
        double r24349184 = r24349179 / r24349183;
        double r24349185 = r24349182 - r24349184;
        double r24349186 = r24349181 / r24349185;
        double r24349187 = -6.619731314741027e-303;
        bool r24349188 = r24349186 <= r24349187;
        double r24349189 = -0.0;
        bool r24349190 = r24349186 <= r24349189;
        double r24349191 = sqrt(r24349182);
        double r24349192 = sqrt(r24349179);
        double r24349193 = sqrt(r24349183);
        double r24349194 = r24349192 / r24349193;
        double r24349195 = r24349191 - r24349194;
        double r24349196 = r24349181 / r24349195;
        double r24349197 = 1.0;
        double r24349198 = r24349191 + r24349194;
        double r24349199 = r24349197 / r24349198;
        double r24349200 = r24349196 * r24349199;
        double r24349201 = r24349190 ? r24349200 : r24349186;
        double r24349202 = r24349188 ? r24349186 : r24349201;
        return r24349202;
}

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.0
Herbie6.1
\[\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))) < -6.619731314741027e-303 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -6.619731314741027e-303 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 59.7

      \[\frac{x + y}{1.0 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt61.0

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

      \[\leadsto \frac{x + y}{1.0 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    5. Applied times-frac61.9

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

      \[\leadsto \frac{x + y}{\color{blue}{\sqrt{1.0} \cdot \sqrt{1.0}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    7. Applied difference-of-squares61.9

      \[\leadsto \frac{x + y}{\color{blue}{\left(\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    8. Applied *-un-lft-identity61.9

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

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

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

Reproduce

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