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

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

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

\end{array}
double f(double x, double y, double z) {
        double r30203861 = x;
        double r30203862 = y;
        double r30203863 = r30203861 + r30203862;
        double r30203864 = 1.0;
        double r30203865 = z;
        double r30203866 = r30203862 / r30203865;
        double r30203867 = r30203864 - r30203866;
        double r30203868 = r30203863 / r30203867;
        return r30203868;
}

double f(double x, double y, double z) {
        double r30203869 = y;
        double r30203870 = x;
        double r30203871 = r30203869 + r30203870;
        double r30203872 = 1.0;
        double r30203873 = z;
        double r30203874 = r30203869 / r30203873;
        double r30203875 = r30203872 - r30203874;
        double r30203876 = r30203871 / r30203875;
        double r30203877 = -2.713922652192976e-295;
        bool r30203878 = r30203876 <= r30203877;
        double r30203879 = -0.0;
        bool r30203880 = r30203876 <= r30203879;
        double r30203881 = 1.0;
        double r30203882 = sqrt(r30203872);
        double r30203883 = sqrt(r30203869);
        double r30203884 = sqrt(r30203873);
        double r30203885 = r30203883 / r30203884;
        double r30203886 = r30203882 - r30203885;
        double r30203887 = sqrt(r30203871);
        double r30203888 = r30203886 / r30203887;
        double r30203889 = r30203882 + r30203885;
        double r30203890 = r30203889 / r30203887;
        double r30203891 = r30203888 * r30203890;
        double r30203892 = r30203881 / r30203891;
        double r30203893 = r30203880 ? r30203892 : r30203876;
        double r30203894 = r30203878 ? r30203876 : r30203893;
        return r30203894;
}

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

Original8.1
Target4.5
Herbie6.5
\[\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))) < -2.713922652192976e-295 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -2.713922652192976e-295 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 59.6

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

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

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

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

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

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

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

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

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

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

Reproduce

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