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

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

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

\end{array}
double f(double x, double y, double z) {
        double r31788373 = x;
        double r31788374 = y;
        double r31788375 = r31788373 + r31788374;
        double r31788376 = 1.0;
        double r31788377 = z;
        double r31788378 = r31788374 / r31788377;
        double r31788379 = r31788376 - r31788378;
        double r31788380 = r31788375 / r31788379;
        return r31788380;
}

double f(double x, double y, double z) {
        double r31788381 = y;
        double r31788382 = x;
        double r31788383 = r31788381 + r31788382;
        double r31788384 = 1.0;
        double r31788385 = z;
        double r31788386 = r31788381 / r31788385;
        double r31788387 = r31788384 - r31788386;
        double r31788388 = r31788383 / r31788387;
        double r31788389 = -5.015331337804172e-270;
        bool r31788390 = r31788388 <= r31788389;
        double r31788391 = -0.0;
        bool r31788392 = r31788388 <= r31788391;
        double r31788393 = 1.0;
        double r31788394 = sqrt(r31788384);
        double r31788395 = sqrt(r31788381);
        double r31788396 = sqrt(r31788385);
        double r31788397 = r31788395 / r31788396;
        double r31788398 = r31788394 - r31788397;
        double r31788399 = r31788393 / r31788398;
        double r31788400 = r31788397 + r31788394;
        double r31788401 = r31788383 / r31788400;
        double r31788402 = r31788399 * r31788401;
        double r31788403 = r31788392 ? r31788402 : r31788388;
        double r31788404 = r31788390 ? r31788388 : r31788403;
        return r31788404;
}

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.2
Herbie6.1
\[\begin{array}{l} \mathbf{if}\;y \lt -3.7429310762689856 \cdot 10^{+171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.5534662456086734 \cdot 10^{+168}:\\ \;\;\;\;\frac{x + y}{1.0 - \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))) < -5.015331337804172e-270 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

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

    1. Initial program 56.8

      \[\frac{x + y}{1.0 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied div-inv56.8

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1.0 - \frac{y}{z}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt58.4

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

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

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

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\sqrt{1.0} \cdot \sqrt{1.0}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    9. Applied difference-of-squares60.4

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\left(\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    10. Applied *-un-lft-identity60.4

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

      \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}\right)}\]
    12. Applied associate-*r*45.8

      \[\leadsto \color{blue}{\left(\left(x + y\right) \cdot \frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}\right) \cdot \frac{1}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}}\]
    13. Simplified45.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -5.015331337804172 \cdot 10^{-270}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\ \;\;\;\;\frac{1}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{y + x}{\frac{\sqrt{y}}{\sqrt{z}} + \sqrt{1.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \end{array}\]

Reproduce

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