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

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

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

\end{array}
double f(double x, double y, double z) {
        double r28248074 = x;
        double r28248075 = y;
        double r28248076 = r28248074 + r28248075;
        double r28248077 = 1.0;
        double r28248078 = z;
        double r28248079 = r28248075 / r28248078;
        double r28248080 = r28248077 - r28248079;
        double r28248081 = r28248076 / r28248080;
        return r28248081;
}

double f(double x, double y, double z) {
        double r28248082 = y;
        double r28248083 = x;
        double r28248084 = r28248082 + r28248083;
        double r28248085 = 1.0;
        double r28248086 = z;
        double r28248087 = r28248082 / r28248086;
        double r28248088 = r28248085 - r28248087;
        double r28248089 = r28248084 / r28248088;
        double r28248090 = -1.98164748767951e-298;
        bool r28248091 = r28248089 <= r28248090;
        double r28248092 = 0.0;
        bool r28248093 = r28248089 <= r28248092;
        double r28248094 = 1.0;
        double r28248095 = sqrt(r28248085);
        double r28248096 = sqrt(r28248082);
        double r28248097 = sqrt(r28248086);
        double r28248098 = r28248096 / r28248097;
        double r28248099 = r28248095 + r28248098;
        double r28248100 = r28248095 - r28248098;
        double r28248101 = r28248084 / r28248100;
        double r28248102 = r28248099 / r28248101;
        double r28248103 = r28248094 / r28248102;
        double r28248104 = r28248093 ? r28248103 : r28248089;
        double r28248105 = r28248091 ? r28248089 : r28248104;
        return r28248105;
}

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{y + x}{1 - \frac{y}{z}} \le -1.981647487679510152082317141904782990318 \cdot 10^{-298}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\frac{y + x}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{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))))