Average Error: 7.2 → 6.6
Time: 9.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le \frac{-7525478665178639}{6.297761573024573878673789321381051618085 \cdot 10^{262}} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot \sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1 \cdot \sqrt{x + y}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le \frac{-7525478665178639}{6.297761573024573878673789321381051618085 \cdot 10^{262}} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r493705 = x;
        double r493706 = y;
        double r493707 = r493705 + r493706;
        double r493708 = 1.0;
        double r493709 = z;
        double r493710 = r493706 / r493709;
        double r493711 = r493708 - r493710;
        double r493712 = r493707 / r493711;
        return r493712;
}

double f(double x, double y, double z) {
        double r493713 = x;
        double r493714 = y;
        double r493715 = r493713 + r493714;
        double r493716 = 1.0;
        double r493717 = z;
        double r493718 = r493714 / r493717;
        double r493719 = r493716 - r493718;
        double r493720 = r493715 / r493719;
        double r493721 = -7525478665178639.0;
        double r493722 = 6.297761573024574e+262;
        double r493723 = r493721 / r493722;
        bool r493724 = r493720 <= r493723;
        double r493725 = -0.0;
        bool r493726 = r493720 <= r493725;
        double r493727 = !r493726;
        bool r493728 = r493724 || r493727;
        double r493729 = 1.0;
        double r493730 = sqrt(r493715);
        double r493731 = r493729 * r493730;
        double r493732 = sqrt(r493716);
        double r493733 = sqrt(r493714);
        double r493734 = sqrt(r493717);
        double r493735 = r493733 / r493734;
        double r493736 = r493732 + r493735;
        double r493737 = r493731 / r493736;
        double r493738 = r493732 - r493735;
        double r493739 = r493731 / r493738;
        double r493740 = r493737 * r493739;
        double r493741 = r493728 ? r493720 : r493740;
        return r493741;
}

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.2
Target4.1
Herbie6.6
\[\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.1949449940138714e-247 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 3.8

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

    if -1.1949449940138714e-247 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 48.9

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

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

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

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

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

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

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

      \[\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)}}{\sqrt{x + y} \cdot \sqrt{x + y}}}\]
    11. Applied times-frac38.1

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}} \cdot \frac{\sqrt{1}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}}\]
    14. Simplified38.1

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\sqrt{1}}{\frac{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}{\sqrt{x + y}}}\]
    15. Simplified38.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le \frac{-7525478665178639}{6.297761573024573878673789321381051618085 \cdot 10^{262}} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot \sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{1 \cdot \sqrt{x + y}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :herbie-target
  (if (< y -3.74293107626898565e171) (* (/ (+ y x) (- y)) z) (if (< y 3.55346624560867344e168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))

  (/ (+ x y) (- 1 (/ y z))))