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

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

\end{array}
double f(double x, double y, double z) {
        double r29750194 = x;
        double r29750195 = y;
        double r29750196 = r29750194 + r29750195;
        double r29750197 = 1.0;
        double r29750198 = z;
        double r29750199 = r29750195 / r29750198;
        double r29750200 = r29750197 - r29750199;
        double r29750201 = r29750196 / r29750200;
        return r29750201;
}

double f(double x, double y, double z) {
        double r29750202 = y;
        double r29750203 = x;
        double r29750204 = r29750202 + r29750203;
        double r29750205 = 1.0;
        double r29750206 = z;
        double r29750207 = r29750202 / r29750206;
        double r29750208 = r29750205 - r29750207;
        double r29750209 = r29750204 / r29750208;
        double r29750210 = -2.713922652192976e-295;
        bool r29750211 = r29750209 <= r29750210;
        double r29750212 = -0.0;
        bool r29750213 = r29750209 <= r29750212;
        double r29750214 = 1.0;
        double r29750215 = sqrt(r29750205);
        double r29750216 = sqrt(r29750202);
        double r29750217 = sqrt(r29750206);
        double r29750218 = r29750216 / r29750217;
        double r29750219 = r29750215 - r29750218;
        double r29750220 = sqrt(r29750204);
        double r29750221 = r29750219 / r29750220;
        double r29750222 = r29750215 + r29750218;
        double r29750223 = r29750222 / r29750220;
        double r29750224 = r29750221 * r29750223;
        double r29750225 = r29750214 / r29750224;
        double r29750226 = r29750213 ? r29750225 : r29750209;
        double r29750227 = r29750211 ? r29750209 : r29750226;
        return r29750227;
}

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

    1. Initial program 0.1

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

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

    1. Initial program 59.6

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

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

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

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

      \[\leadsto \frac{1}{\frac{1 - \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.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y + x}{1 - \frac{y}{z}} \le -2.713922652192975851304047207930983359652 \cdot 10^{-295}:\\ \;\;\;\;\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}}}{\sqrt{y + x}} \cdot \frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{y + x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \end{array}\]

Reproduce

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