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

\end{array}
double f(double x, double y, double z) {
        double r410183 = x;
        double r410184 = y;
        double r410185 = r410183 + r410184;
        double r410186 = 1.0;
        double r410187 = z;
        double r410188 = r410184 / r410187;
        double r410189 = r410186 - r410188;
        double r410190 = r410185 / r410189;
        return r410190;
}

double f(double x, double y, double z) {
        double r410191 = x;
        double r410192 = y;
        double r410193 = r410191 + r410192;
        double r410194 = 1.0;
        double r410195 = z;
        double r410196 = r410192 / r410195;
        double r410197 = r410194 - r410196;
        double r410198 = r410193 / r410197;
        double r410199 = -1.6793711944345364e-273;
        bool r410200 = r410198 <= r410199;
        double r410201 = 0.0;
        bool r410202 = r410198 <= r410201;
        double r410203 = !r410202;
        bool r410204 = r410200 || r410203;
        double r410205 = 1.0;
        double r410206 = sqrt(r410194);
        double r410207 = sqrt(r410192);
        double r410208 = sqrt(r410195);
        double r410209 = r410207 / r410208;
        double r410210 = r410206 + r410209;
        double r410211 = r410205 / r410210;
        double r410212 = r410206 - r410209;
        double r410213 = r410193 / r410212;
        double r410214 = r410211 * r410213;
        double r410215 = r410204 ? r410198 : r410214;
        return r410215;
}

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.3
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))) < -1.6793711944345364e-273 or 0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.0

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

    if -1.6793711944345364e-273 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 55.0

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt59.4

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

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

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

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

      \[\leadsto \frac{x + y}{\color{blue}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    8. Applied *-un-lft-identity62.3

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{x + y}{\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 -1.679371194434536427238190930168084149811 \cdot 10^{-273} \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{x + y}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]

Reproduce

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