Average Error: 7.6 → 6.4
Time: 15.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -2.869692918571675329109593574597536633393 \cdot 10^{-291} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le 0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{y + x}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{y + x}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -2.869692918571675329109593574597536633393 \cdot 10^{-291} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le 0.0\right):\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r397588 = x;
        double r397589 = y;
        double r397590 = r397588 + r397589;
        double r397591 = 1.0;
        double r397592 = z;
        double r397593 = r397589 / r397592;
        double r397594 = r397591 - r397593;
        double r397595 = r397590 / r397594;
        return r397595;
}

double f(double x, double y, double z) {
        double r397596 = x;
        double r397597 = y;
        double r397598 = r397596 + r397597;
        double r397599 = 1.0;
        double r397600 = z;
        double r397601 = r397597 / r397600;
        double r397602 = r397599 - r397601;
        double r397603 = r397598 / r397602;
        double r397604 = -2.8696929185716753e-291;
        bool r397605 = r397603 <= r397604;
        double r397606 = 0.0;
        bool r397607 = r397603 <= r397606;
        double r397608 = !r397607;
        bool r397609 = r397605 || r397608;
        double r397610 = r397597 + r397596;
        double r397611 = sqrt(r397610);
        double r397612 = sqrt(r397599);
        double r397613 = sqrt(r397597);
        double r397614 = sqrt(r397600);
        double r397615 = r397613 / r397614;
        double r397616 = r397612 + r397615;
        double r397617 = r397611 / r397616;
        double r397618 = r397612 - r397615;
        double r397619 = r397611 / r397618;
        double r397620 = r397617 * r397619;
        double r397621 = r397609 ? r397603 : r397620;
        return r397621;
}

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.2
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))) < -2.8696929185716753e-291 or 0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.1

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

    if -2.8696929185716753e-291 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 58.6

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(1 - \frac{y}{z}\right) \cdot \frac{1}{x + y}}}\]
    6. Applied associate-/r*58.6

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

      \[\leadsto \frac{\frac{1}{1 - \frac{y}{z}}}{\frac{1}{\color{blue}{\sqrt{x + y} \cdot \sqrt{x + y}}}}\]
    9. Applied add-cube-cbrt61.5

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

      \[\leadsto \frac{\frac{1}{1 - \frac{y}{z}}}{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x + y}}}}\]
    11. Applied add-sqr-sqrt63.3

      \[\leadsto \frac{\frac{1}{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x + y}}}\]
    12. Applied add-sqr-sqrt63.4

      \[\leadsto \frac{\frac{1}{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x + y}}}\]
    13. Applied times-frac63.4

      \[\leadsto \frac{\frac{1}{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x + y}}}\]
    14. Applied add-sqr-sqrt63.4

      \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x + y}}}\]
    15. Applied difference-of-squares63.4

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

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x + y}}}\]
    18. Applied times-frac63.4

      \[\leadsto \color{blue}{\frac{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{x + y}}} \cdot \frac{\frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt[3]{1}}{\sqrt{x + y}}}}\]
    19. Simplified63.4

      \[\leadsto \color{blue}{\frac{\sqrt{y + x}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\frac{\sqrt[3]{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt[3]{1}}{\sqrt{x + y}}}\]
    20. Simplified63.4

      \[\leadsto \frac{\sqrt{y + x}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \color{blue}{\frac{\sqrt{y + x}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}\]
  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 -2.869692918571675329109593574597536633393 \cdot 10^{-291} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le 0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{y + x}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{y + x}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]

Reproduce

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