Average Error: 7.8 → 6.3
Time: 23.3s
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 r37717996 = x;
        double r37717997 = y;
        double r37717998 = r37717996 + r37717997;
        double r37717999 = 1.0;
        double r37718000 = z;
        double r37718001 = r37717997 / r37718000;
        double r37718002 = r37717999 - r37718001;
        double r37718003 = r37717998 / r37718002;
        return r37718003;
}

double f(double x, double y, double z) {
        double r37718004 = x;
        double r37718005 = y;
        double r37718006 = r37718004 + r37718005;
        double r37718007 = 1.0;
        double r37718008 = z;
        double r37718009 = r37718005 / r37718008;
        double r37718010 = r37718007 - r37718009;
        double r37718011 = r37718006 / r37718010;
        double r37718012 = -1.98164748767951e-298;
        bool r37718013 = r37718011 <= r37718012;
        double r37718014 = 0.0;
        bool r37718015 = r37718011 <= r37718014;
        double r37718016 = 1.0;
        double r37718017 = sqrt(r37718007);
        double r37718018 = sqrt(r37718005);
        double r37718019 = sqrt(r37718008);
        double r37718020 = r37718018 / r37718019;
        double r37718021 = r37718017 + r37718020;
        double r37718022 = r37718017 - r37718020;
        double r37718023 = r37718006 / r37718022;
        double r37718024 = r37718021 / r37718023;
        double r37718025 = r37718016 / r37718024;
        double r37718026 = r37718015 ? r37718025 : r37718011;
        double r37718027 = r37718013 ? r37718011 : r37718026;
        return r37718027;
}

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