Average Error: 7.6 → 6.1
Time: 13.7s
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{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 -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{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 r29404788 = x;
        double r29404789 = y;
        double r29404790 = r29404788 + r29404789;
        double r29404791 = 1.0;
        double r29404792 = z;
        double r29404793 = r29404789 / r29404792;
        double r29404794 = r29404791 - r29404793;
        double r29404795 = r29404790 / r29404794;
        return r29404795;
}

double f(double x, double y, double z) {
        double r29404796 = y;
        double r29404797 = x;
        double r29404798 = r29404796 + r29404797;
        double r29404799 = 1.0;
        double r29404800 = z;
        double r29404801 = r29404796 / r29404800;
        double r29404802 = r29404799 - r29404801;
        double r29404803 = r29404798 / r29404802;
        double r29404804 = -5.015331337804172e-270;
        bool r29404805 = r29404803 <= r29404804;
        double r29404806 = -0.0;
        bool r29404807 = r29404803 <= r29404806;
        double r29404808 = sqrt(r29404799);
        double r29404809 = sqrt(r29404796);
        double r29404810 = sqrt(r29404800);
        double r29404811 = r29404809 / r29404810;
        double r29404812 = r29404808 - r29404811;
        double r29404813 = r29404798 / r29404812;
        double r29404814 = 1.0;
        double r29404815 = r29404808 + r29404811;
        double r29404816 = r29404814 / r29404815;
        double r29404817 = r29404813 * r29404816;
        double r29404818 = r29404807 ? r29404817 : r29404803;
        double r29404819 = r29404805 ? r29404803 : r29404818;
        return r29404819;
}

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 add-sqr-sqrt58.4

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

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

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

      \[\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-squares60.4

      \[\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-identity60.4

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

      \[\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 -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{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 2019158 +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))))