Average Error: 7.8 → 6.3
Time: 20.8s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.981647487679510152082317141904782990318 \cdot 10^{-298}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{x + y}{1 - \frac{y}{z}} \le 0.0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\frac{x + y}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.981647487679510152082317141904782990318 \cdot 10^{-298}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r44401822 = x;
        double r44401823 = y;
        double r44401824 = r44401822 + r44401823;
        double r44401825 = 1.0;
        double r44401826 = z;
        double r44401827 = r44401823 / r44401826;
        double r44401828 = r44401825 - r44401827;
        double r44401829 = r44401824 / r44401828;
        return r44401829;
}

double f(double x, double y, double z) {
        double r44401830 = x;
        double r44401831 = y;
        double r44401832 = r44401830 + r44401831;
        double r44401833 = 1.0;
        double r44401834 = z;
        double r44401835 = r44401831 / r44401834;
        double r44401836 = r44401833 - r44401835;
        double r44401837 = r44401832 / r44401836;
        double r44401838 = -1.98164748767951e-298;
        bool r44401839 = r44401837 <= r44401838;
        double r44401840 = 0.0;
        bool r44401841 = r44401837 <= r44401840;
        double r44401842 = 1.0;
        double r44401843 = sqrt(r44401833);
        double r44401844 = sqrt(r44401831);
        double r44401845 = sqrt(r44401834);
        double r44401846 = r44401844 / r44401845;
        double r44401847 = r44401843 + r44401846;
        double r44401848 = r44401843 - r44401846;
        double r44401849 = r44401832 / r44401848;
        double r44401850 = r44401847 / r44401849;
        double r44401851 = r44401842 / r44401850;
        double r44401852 = r44401841 ? r44401851 : r44401837;
        double r44401853 = r44401839 ? r44401837 : r44401852;
        return r44401853;
}

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.8
Target4.1
Herbie6.3
\[\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.98164748767951e-298 or 0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -1.98164748767951e-298 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 59.7

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt61.6

      \[\leadsto \frac{1}{\frac{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}{x + y}}\]
    6. Applied add-sqr-sqrt62.7

      \[\leadsto \frac{1}{\frac{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}{x + y}}\]
    7. Applied times-frac62.7

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}{x + y}}\]
    8. Applied add-sqr-sqrt62.7

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

      \[\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)}}{x + y}}\]
    10. Applied associate-/l*47.9

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

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

Reproduce

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