Average Error: 7.2 → 6.6
Time: 19.3s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.194944994013871437284920410941093036324 \cdot 10^{-247} \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 -1.194944994013871437284920410941093036324 \cdot 10^{-247} \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 r358185 = x;
        double r358186 = y;
        double r358187 = r358185 + r358186;
        double r358188 = 1.0;
        double r358189 = z;
        double r358190 = r358186 / r358189;
        double r358191 = r358188 - r358190;
        double r358192 = r358187 / r358191;
        return r358192;
}

double f(double x, double y, double z) {
        double r358193 = x;
        double r358194 = y;
        double r358195 = r358193 + r358194;
        double r358196 = 1.0;
        double r358197 = z;
        double r358198 = r358194 / r358197;
        double r358199 = r358196 - r358198;
        double r358200 = r358195 / r358199;
        double r358201 = -1.1949449940138714e-247;
        bool r358202 = r358200 <= r358201;
        double r358203 = -0.0;
        bool r358204 = r358200 <= r358203;
        double r358205 = !r358204;
        bool r358206 = r358202 || r358205;
        double r358207 = r358194 + r358193;
        double r358208 = sqrt(r358207);
        double r358209 = sqrt(r358196);
        double r358210 = sqrt(r358194);
        double r358211 = sqrt(r358197);
        double r358212 = r358210 / r358211;
        double r358213 = r358209 + r358212;
        double r358214 = r358208 / r358213;
        double r358215 = r358209 - r358212;
        double r358216 = r358208 / r358215;
        double r358217 = r358214 * r358216;
        double r358218 = r358206 ? r358200 : r358217;
        return r358218;
}

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.2
Target4.1
Herbie6.6
\[\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.1949449940138714e-247 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 3.8

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

    if -1.1949449940138714e-247 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 48.9

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

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

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

      \[\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-sqrt59.4

      \[\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-frac59.4

      \[\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-sqrt59.4

      \[\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-squares59.4

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

      \[\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 add-cube-cbrt38.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.194944994013871437284920410941093036324 \cdot 10^{-247} \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 2019303 +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.74293107626898565e171) (* (/ (+ y x) (- y)) z) (if (< y 3.55346624560867344e168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))

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