Average Error: 7.6 → 6.4
Time: 2.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -9.340220995992204435937211078763363155616 \cdot 10^{-288} \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{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -9.340220995992204435937211078763363155616 \cdot 10^{-288} \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{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\\

\end{array}
double f(double x, double y, double z) {
        double r614402 = x;
        double r614403 = y;
        double r614404 = r614402 + r614403;
        double r614405 = 1.0;
        double r614406 = z;
        double r614407 = r614403 / r614406;
        double r614408 = r614405 - r614407;
        double r614409 = r614404 / r614408;
        return r614409;
}

double f(double x, double y, double z) {
        double r614410 = x;
        double r614411 = y;
        double r614412 = r614410 + r614411;
        double r614413 = 1.0;
        double r614414 = z;
        double r614415 = r614411 / r614414;
        double r614416 = r614413 - r614415;
        double r614417 = r614412 / r614416;
        double r614418 = -9.340220995992204e-288;
        bool r614419 = r614417 <= r614418;
        double r614420 = -0.0;
        bool r614421 = r614417 <= r614420;
        double r614422 = !r614421;
        bool r614423 = r614419 || r614422;
        double r614424 = sqrt(r614412);
        double r614425 = sqrt(r614413);
        double r614426 = sqrt(r614411);
        double r614427 = sqrt(r614414);
        double r614428 = r614426 / r614427;
        double r614429 = r614425 + r614428;
        double r614430 = r614424 / r614429;
        double r614431 = r614425 - r614428;
        double r614432 = r614431 / r614424;
        double r614433 = r614430 / r614432;
        double r614434 = r614423 ? r614417 : r614433;
        return r614434;
}

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.6
Target3.9
Herbie6.4
\[\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))) < -9.340220995992204e-288 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.1

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied div-inv4.2

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}}\]
    4. Using strategy rm
    5. Applied un-div-inv4.1

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

    if -9.340220995992204e-288 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 57.3

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

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

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

      \[\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-sqrt61.0

      \[\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-frac61.0

      \[\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-sqrt61.0

      \[\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-squares61.0

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

      \[\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}}}}\]
    12. Applied associate-/r*35.5

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}}\]
    13. Simplified35.4

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

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

Reproduce

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