Average Error: 7.7 → 6.2
Time: 45.5s
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{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 -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{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 r28029039 = x;
        double r28029040 = y;
        double r28029041 = r28029039 + r28029040;
        double r28029042 = 1.0;
        double r28029043 = z;
        double r28029044 = r28029040 / r28029043;
        double r28029045 = r28029042 - r28029044;
        double r28029046 = r28029041 / r28029045;
        return r28029046;
}

double f(double x, double y, double z) {
        double r28029047 = y;
        double r28029048 = x;
        double r28029049 = r28029047 + r28029048;
        double r28029050 = 1.0;
        double r28029051 = z;
        double r28029052 = r28029047 / r28029051;
        double r28029053 = r28029050 - r28029052;
        double r28029054 = r28029049 / r28029053;
        double r28029055 = -5.127395520009548e-284;
        bool r28029056 = r28029054 <= r28029055;
        double r28029057 = -0.0;
        bool r28029058 = r28029054 <= r28029057;
        double r28029059 = sqrt(r28029050);
        double r28029060 = sqrt(r28029047);
        double r28029061 = sqrt(r28029051);
        double r28029062 = r28029060 / r28029061;
        double r28029063 = r28029059 - r28029062;
        double r28029064 = r28029049 / r28029063;
        double r28029065 = 1.0;
        double r28029066 = r28029059 + r28029062;
        double r28029067 = r28029065 / r28029066;
        double r28029068 = r28029064 * r28029067;
        double r28029069 = r28029058 ? r28029068 : r28029054;
        double r28029070 = r28029056 ? r28029054 : r28029069;
        return r28029070;
}

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 add-sqr-sqrt60.9

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

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

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

      \[\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-squares62.5

      \[\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-identity62.5

      \[\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.2

      \[\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.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{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 2019165 +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))))