Average Error: 7.7 → 6.4
Time: 14.9s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1 - \frac{y}{z}} \le -4.61291755031202367093527746970482296077 \cdot 10^{-270}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{y}}{\sqrt{z}} + \sqrt{1}} \cdot \frac{y + x}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{y + x}{1 - \frac{y}{z}} \le -4.61291755031202367093527746970482296077 \cdot 10^{-270}:\\
\;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\

\mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\
\;\;\;\;\frac{1}{\frac{\sqrt{y}}{\sqrt{z}} + \sqrt{1}} \cdot \frac{y + x}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r25611357 = x;
        double r25611358 = y;
        double r25611359 = r25611357 + r25611358;
        double r25611360 = 1.0;
        double r25611361 = z;
        double r25611362 = r25611358 / r25611361;
        double r25611363 = r25611360 - r25611362;
        double r25611364 = r25611359 / r25611363;
        return r25611364;
}

double f(double x, double y, double z) {
        double r25611365 = y;
        double r25611366 = x;
        double r25611367 = r25611365 + r25611366;
        double r25611368 = 1.0;
        double r25611369 = z;
        double r25611370 = r25611365 / r25611369;
        double r25611371 = r25611368 - r25611370;
        double r25611372 = r25611367 / r25611371;
        double r25611373 = -4.612917550312024e-270;
        bool r25611374 = r25611372 <= r25611373;
        double r25611375 = 0.0;
        bool r25611376 = r25611372 <= r25611375;
        double r25611377 = 1.0;
        double r25611378 = sqrt(r25611365);
        double r25611379 = sqrt(r25611369);
        double r25611380 = r25611378 / r25611379;
        double r25611381 = sqrt(r25611368);
        double r25611382 = r25611380 + r25611381;
        double r25611383 = r25611377 / r25611382;
        double r25611384 = r25611381 - r25611380;
        double r25611385 = r25611367 / r25611384;
        double r25611386 = r25611383 * r25611385;
        double r25611387 = r25611376 ? r25611386 : r25611372;
        double r25611388 = r25611374 ? r25611372 : r25611387;
        return r25611388;
}

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

    1. Initial program 0.1

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

    if -4.612917550312024e-270 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 57.1

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

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

      \[\leadsto \frac{1}{\frac{1 - \frac{y}{z}}{\color{blue}{1 \cdot \left(x + y\right)}}}\]
    6. Applied add-sqr-sqrt59.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-sqrt61.9

      \[\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-frac61.9

      \[\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-sqrt61.9

      \[\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-squares61.9

      \[\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-frac47.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-cube-cbrt47.7

      \[\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}}}{1} \cdot \frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\]
    13. Applied times-frac47.7

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

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

      \[\leadsto \frac{1}{\frac{\sqrt{y}}{\sqrt{z}} + \sqrt{1}} \cdot \color{blue}{\frac{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{y + x}{1 - \frac{y}{z}} \le -4.61291755031202367093527746970482296077 \cdot 10^{-270}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{y}}{\sqrt{z}} + \sqrt{1}} \cdot \frac{y + x}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"

  :herbie-target
  (if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))

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