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

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

\end{array}
double f(double x, double y, double z) {
        double r533419 = x;
        double r533420 = y;
        double r533421 = r533419 + r533420;
        double r533422 = 1.0;
        double r533423 = z;
        double r533424 = r533420 / r533423;
        double r533425 = r533422 - r533424;
        double r533426 = r533421 / r533425;
        return r533426;
}

double f(double x, double y, double z) {
        double r533427 = x;
        double r533428 = y;
        double r533429 = r533427 + r533428;
        double r533430 = 1.0;
        double r533431 = z;
        double r533432 = r533428 / r533431;
        double r533433 = r533430 - r533432;
        double r533434 = r533429 / r533433;
        double r533435 = -1.9112866677972818e-283;
        bool r533436 = r533434 <= r533435;
        double r533437 = -0.0;
        bool r533438 = r533434 <= r533437;
        double r533439 = !r533438;
        bool r533440 = r533436 || r533439;
        double r533441 = 1.0;
        double r533442 = sqrt(r533430);
        double r533443 = sqrt(r533428);
        double r533444 = sqrt(r533431);
        double r533445 = r533443 / r533444;
        double r533446 = r533442 + r533445;
        double r533447 = r533441 / r533446;
        double r533448 = r533442 - r533445;
        double r533449 = r533448 / r533429;
        double r533450 = r533447 / r533449;
        double r533451 = r533440 ? r533434 : r533450;
        return r533451;
}

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.9
Target4.0
Herbie6.5
\[\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.9112866677972818e-283 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 4.2

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

    if -1.9112866677972818e-283 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 56.4

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

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

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

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

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

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

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

      \[\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-frac35.2

      \[\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 associate-/r*35.2

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{1}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}}\]
    13. Simplified35.2

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.911286667797281767261583807561479254136 \cdot 10^{-283} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{x + y}}\\ \end{array}\]

Reproduce

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