Average Error: 7.8 → 6.3
Time: 18.7s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1 - \frac{y}{z}} \le -1.981647487679510152082317141904782990318 \cdot 10^{-298}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\frac{y + x}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{y + x}{1 - \frac{y}{z}} \le -1.981647487679510152082317141904782990318 \cdot 10^{-298}:\\
\;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r26047145 = x;
        double r26047146 = y;
        double r26047147 = r26047145 + r26047146;
        double r26047148 = 1.0;
        double r26047149 = z;
        double r26047150 = r26047146 / r26047149;
        double r26047151 = r26047148 - r26047150;
        double r26047152 = r26047147 / r26047151;
        return r26047152;
}

double f(double x, double y, double z) {
        double r26047153 = y;
        double r26047154 = x;
        double r26047155 = r26047153 + r26047154;
        double r26047156 = 1.0;
        double r26047157 = z;
        double r26047158 = r26047153 / r26047157;
        double r26047159 = r26047156 - r26047158;
        double r26047160 = r26047155 / r26047159;
        double r26047161 = -1.98164748767951e-298;
        bool r26047162 = r26047160 <= r26047161;
        double r26047163 = 0.0;
        bool r26047164 = r26047160 <= r26047163;
        double r26047165 = 1.0;
        double r26047166 = sqrt(r26047156);
        double r26047167 = sqrt(r26047153);
        double r26047168 = sqrt(r26047157);
        double r26047169 = r26047167 / r26047168;
        double r26047170 = r26047166 + r26047169;
        double r26047171 = r26047166 - r26047169;
        double r26047172 = r26047155 / r26047171;
        double r26047173 = r26047170 / r26047172;
        double r26047174 = r26047165 / r26047173;
        double r26047175 = r26047164 ? r26047174 : r26047160;
        double r26047176 = r26047162 ? r26047160 : r26047175;
        return r26047176;
}

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.8
Target4.1
Herbie6.3
\[\begin{array}{l} \mathbf{if}\;y \lt -3.742931076268985646434612946949172132145 \cdot 10^{171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.553466245608673435460441960303815115662 \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))) < -1.98164748767951e-298 or 0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -1.98164748767951e-298 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 59.7

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}{x + y}}\]
    10. Applied associate-/l*47.9

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

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

Reproduce

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