Average Error: 8.0 → 6.8
Time: 3.7s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -8.7218135427022044 \cdot 10^{-281} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le 0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -8.7218135427022044 \cdot 10^{-281} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le 0.0\right):\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y}}}\\

\end{array}
double f(double x, double y, double z) {
        double r561261 = x;
        double r561262 = y;
        double r561263 = r561261 + r561262;
        double r561264 = 1.0;
        double r561265 = z;
        double r561266 = r561262 / r561265;
        double r561267 = r561264 - r561266;
        double r561268 = r561263 / r561267;
        return r561268;
}

double f(double x, double y, double z) {
        double r561269 = x;
        double r561270 = y;
        double r561271 = r561269 + r561270;
        double r561272 = 1.0;
        double r561273 = z;
        double r561274 = r561270 / r561273;
        double r561275 = r561272 - r561274;
        double r561276 = r561271 / r561275;
        double r561277 = -8.721813542702204e-281;
        bool r561278 = r561276 <= r561277;
        double r561279 = 0.0;
        bool r561280 = r561276 <= r561279;
        double r561281 = !r561280;
        bool r561282 = r561278 || r561281;
        double r561283 = cbrt(r561271);
        double r561284 = r561283 * r561283;
        double r561285 = sqrt(r561272);
        double r561286 = sqrt(r561270);
        double r561287 = sqrt(r561273);
        double r561288 = r561286 / r561287;
        double r561289 = r561285 + r561288;
        double r561290 = r561284 / r561289;
        double r561291 = r561285 - r561288;
        double r561292 = r561291 / r561283;
        double r561293 = r561290 / r561292;
        double r561294 = r561282 ? r561276 : r561293;
        return r561294;
}

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

    1. Initial program 0.1

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

    if -8.721813542702204e-281 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 58.0

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt58.0

      \[\leadsto \frac{1}{\frac{1 - \frac{y}{z}}{\color{blue}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}}\]
    6. Applied add-sqr-sqrt60.4

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

      \[\leadsto \frac{1}{\frac{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}\]
    8. Applied times-frac62.6

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}\]
    9. Applied add-sqr-sqrt62.6

      \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}\]
    10. Applied difference-of-squares62.6

      \[\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)}}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}\]
    11. Applied times-frac49.0

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}} \cdot \frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y}}}}\]
    12. Applied associate-/r*49.0

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y}}}}\]
    13. Simplified49.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -8.7218135427022044 \cdot 10^{-281} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le 0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt[3]{x + y}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020033 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :herbie-target
  (if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))

  (/ (+ x y) (- 1 (/ y z))))