Average Error: 7.6 → 6.3
Time: 8.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.087750381558417553613496340902486478305 \cdot 10^{-303} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1 \cdot \left(x + y\right)}{\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 -1.087750381558417553613496340902486478305 \cdot 10^{-303} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r533997 = x;
        double r533998 = y;
        double r533999 = r533997 + r533998;
        double r534000 = 1.0;
        double r534001 = z;
        double r534002 = r533998 / r534001;
        double r534003 = r534000 - r534002;
        double r534004 = r533999 / r534003;
        return r534004;
}

double f(double x, double y, double z) {
        double r534005 = x;
        double r534006 = y;
        double r534007 = r534005 + r534006;
        double r534008 = 1.0;
        double r534009 = z;
        double r534010 = r534006 / r534009;
        double r534011 = r534008 - r534010;
        double r534012 = r534007 / r534011;
        double r534013 = -1.0877503815584176e-303;
        bool r534014 = r534012 <= r534013;
        double r534015 = -0.0;
        bool r534016 = r534012 <= r534015;
        double r534017 = !r534016;
        bool r534018 = r534014 || r534017;
        double r534019 = 1.0;
        double r534020 = sqrt(r534008);
        double r534021 = sqrt(r534006);
        double r534022 = sqrt(r534009);
        double r534023 = r534021 / r534022;
        double r534024 = r534020 + r534023;
        double r534025 = r534019 / r534024;
        double r534026 = r534019 * r534007;
        double r534027 = r534020 - r534023;
        double r534028 = r534026 / r534027;
        double r534029 = r534025 * r534028;
        double r534030 = r534018 ? r534012 : r534029;
        return r534030;
}

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

    1. Initial program 4.2

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

    if -1.0877503815584176e-303 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 60.1

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

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

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

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

      \[\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-frac62.1

      \[\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-sqrt62.1

      \[\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-squares62.1

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

      \[\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 add-sqr-sqrt36.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{1}} \cdot \frac{\sqrt{1}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}}\]
    14. Simplified36.7

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\sqrt{1}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\]
    15. Simplified36.7

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

Reproduce

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