Average Error: 7.7 → 6.4
Time: 14.9s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1 - \frac{y}{z}} \le -4.61291755031202367093527746970482296077 \cdot 10^{-270}:\\ \;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\ \;\;\;\;\frac{y + x}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\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 -4.61291755031202367093527746970482296077 \cdot 10^{-270}:\\
\;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\

\mathbf{elif}\;\frac{y + x}{1 - \frac{y}{z}} \le 0.0:\\
\;\;\;\;\frac{y + x}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\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 r22352619 = x;
        double r22352620 = y;
        double r22352621 = r22352619 + r22352620;
        double r22352622 = 1.0;
        double r22352623 = z;
        double r22352624 = r22352620 / r22352623;
        double r22352625 = r22352622 - r22352624;
        double r22352626 = r22352621 / r22352625;
        return r22352626;
}

double f(double x, double y, double z) {
        double r22352627 = y;
        double r22352628 = x;
        double r22352629 = r22352627 + r22352628;
        double r22352630 = 1.0;
        double r22352631 = z;
        double r22352632 = r22352627 / r22352631;
        double r22352633 = r22352630 - r22352632;
        double r22352634 = r22352629 / r22352633;
        double r22352635 = -4.612917550312024e-270;
        bool r22352636 = r22352634 <= r22352635;
        double r22352637 = 0.0;
        bool r22352638 = r22352634 <= r22352637;
        double r22352639 = sqrt(r22352630);
        double r22352640 = sqrt(r22352627);
        double r22352641 = sqrt(r22352631);
        double r22352642 = r22352640 / r22352641;
        double r22352643 = r22352639 + r22352642;
        double r22352644 = r22352629 / r22352643;
        double r22352645 = 1.0;
        double r22352646 = r22352639 - r22352642;
        double r22352647 = r22352645 / r22352646;
        double r22352648 = r22352644 * r22352647;
        double r22352649 = r22352638 ? r22352648 : r22352634;
        double r22352650 = r22352636 ? r22352634 : r22352649;
        return r22352650;
}

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.7
Target4.2
Herbie6.4
\[\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))) < -4.612917550312024e-270 or 0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -4.612917550312024e-270 < (/ (+ x y) (- 1.0 (/ y z))) < 0.0

    1. Initial program 57.1

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied div-inv57.1

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt59.5

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\]
    6. Applied add-sqr-sqrt61.9

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

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    8. Applied add-sqr-sqrt61.9

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    9. Applied difference-of-squares61.9

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    10. Applied *-un-lft-identity61.9

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

      \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\right)}\]
    12. Applied associate-*r*47.7

      \[\leadsto \color{blue}{\left(\left(x + y\right) \cdot \frac{1}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}\right) \cdot \frac{1}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}\]
    13. Simplified47.7

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

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

Reproduce

herbie shell --seed 2019172 +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))))