Average Error: 7.6 → 6.3
Time: 4.6s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -7.006132763690498121083581548306386135093 \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{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -7.006132763690498121083581548306386135093 \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{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\\

\end{array}
double f(double x, double y, double z) {
        double r667546 = x;
        double r667547 = y;
        double r667548 = r667546 + r667547;
        double r667549 = 1.0;
        double r667550 = z;
        double r667551 = r667547 / r667550;
        double r667552 = r667549 - r667551;
        double r667553 = r667548 / r667552;
        return r667553;
}

double f(double x, double y, double z) {
        double r667554 = x;
        double r667555 = y;
        double r667556 = r667554 + r667555;
        double r667557 = 1.0;
        double r667558 = z;
        double r667559 = r667555 / r667558;
        double r667560 = r667557 - r667559;
        double r667561 = r667556 / r667560;
        double r667562 = -7.006132763690498e-281;
        bool r667563 = r667561 <= r667562;
        double r667564 = -0.0;
        bool r667565 = r667561 <= r667564;
        double r667566 = !r667565;
        bool r667567 = r667563 || r667566;
        double r667568 = 1.0;
        double r667569 = sqrt(r667557);
        double r667570 = sqrt(r667555);
        double r667571 = sqrt(r667558);
        double r667572 = r667570 / r667571;
        double r667573 = r667569 + r667572;
        double r667574 = r667568 / r667573;
        double r667575 = r667569 - r667572;
        double r667576 = r667575 / r667556;
        double r667577 = r667574 / r667576;
        double r667578 = r667567 ? r667561 : r667577;
        return r667578;
}

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
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))) < -7.006132763690498e-281 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.1

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

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

    1. Initial program 56.9

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity57.0

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

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

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

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

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

      \[\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)}}{1 \cdot \left(x + y\right)}}\]
    11. Applied times-frac34.8

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

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

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

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

Reproduce

herbie shell --seed 2019322 
(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.74293107626898565e171) (* (/ (+ y x) (- y)) z) (if (< y 3.55346624560867344e168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))

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