Average Error: 7.7 → 6.1
Time: 14.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 -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 r29696462 = x;
        double r29696463 = y;
        double r29696464 = r29696462 + r29696463;
        double r29696465 = 1.0;
        double r29696466 = z;
        double r29696467 = r29696463 / r29696466;
        double r29696468 = r29696465 - r29696467;
        double r29696469 = r29696464 / r29696468;
        return r29696469;
}

double f(double x, double y, double z) {
        double r29696470 = y;
        double r29696471 = x;
        double r29696472 = r29696470 + r29696471;
        double r29696473 = 1.0;
        double r29696474 = z;
        double r29696475 = r29696470 / r29696474;
        double r29696476 = r29696473 - r29696475;
        double r29696477 = r29696472 / r29696476;
        double r29696478 = -6.619731314741027e-303;
        bool r29696479 = r29696477 <= r29696478;
        double r29696480 = -0.0;
        bool r29696481 = r29696477 <= r29696480;
        double r29696482 = sqrt(r29696473);
        double r29696483 = sqrt(r29696470);
        double r29696484 = sqrt(r29696474);
        double r29696485 = r29696483 / r29696484;
        double r29696486 = r29696482 - r29696485;
        double r29696487 = r29696472 / r29696486;
        double r29696488 = 1.0;
        double r29696489 = r29696482 + r29696485;
        double r29696490 = r29696488 / r29696489;
        double r29696491 = r29696487 * r29696490;
        double r29696492 = r29696481 ? r29696491 : r29696477;
        double r29696493 = r29696479 ? r29696477 : r29696492;
        return r29696493;
}

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))))