Average Error: 7.7 → 6.1
Time: 15.6s
Precision: 64
\[\frac{x + y}{1.0 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -6.619731314741027 \cdot 10^{-303}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\ \;\;\;\;\frac{y + x}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}\\ \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 -6.619731314741027 \cdot 10^{-303}:\\
\;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r31195445 = x;
        double r31195446 = y;
        double r31195447 = r31195445 + r31195446;
        double r31195448 = 1.0;
        double r31195449 = z;
        double r31195450 = r31195446 / r31195449;
        double r31195451 = r31195448 - r31195450;
        double r31195452 = r31195447 / r31195451;
        return r31195452;
}

double f(double x, double y, double z) {
        double r31195453 = y;
        double r31195454 = x;
        double r31195455 = r31195453 + r31195454;
        double r31195456 = 1.0;
        double r31195457 = z;
        double r31195458 = r31195453 / r31195457;
        double r31195459 = r31195456 - r31195458;
        double r31195460 = r31195455 / r31195459;
        double r31195461 = -6.619731314741027e-303;
        bool r31195462 = r31195460 <= r31195461;
        double r31195463 = -0.0;
        bool r31195464 = r31195460 <= r31195463;
        double r31195465 = sqrt(r31195456);
        double r31195466 = sqrt(r31195453);
        double r31195467 = sqrt(r31195457);
        double r31195468 = r31195466 / r31195467;
        double r31195469 = r31195465 - r31195468;
        double r31195470 = r31195455 / r31195469;
        double r31195471 = 1.0;
        double r31195472 = r31195465 + r31195468;
        double r31195473 = r31195471 / r31195472;
        double r31195474 = r31195470 * r31195473;
        double r31195475 = r31195464 ? r31195474 : r31195460;
        double r31195476 = r31195462 ? r31195460 : r31195475;
        return r31195476;
}

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

    1. Initial program 0.1

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

    if -6.619731314741027e-303 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 59.7

      \[\frac{x + y}{1.0 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt61.0

      \[\leadsto \frac{x + y}{1.0 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\]
    4. Applied add-sqr-sqrt61.9

      \[\leadsto \frac{x + y}{1.0 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    5. Applied times-frac61.9

      \[\leadsto \frac{x + y}{1.0 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    6. Applied add-sqr-sqrt61.9

      \[\leadsto \frac{x + y}{\color{blue}{\sqrt{1.0} \cdot \sqrt{1.0}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    7. Applied difference-of-squares61.9

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

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

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

Reproduce

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