Average Error: 7.5 → 6.2
Time: 11.8s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.801559318634141379499295463502958423038 \cdot 10^{-285} \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}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\frac{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 -1.801559318634141379499295463502958423038 \cdot 10^{-285} \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}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\frac{x + y}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}}\\

\end{array}
double f(double x, double y, double z) {
        double r389039 = x;
        double r389040 = y;
        double r389041 = r389039 + r389040;
        double r389042 = 1.0;
        double r389043 = z;
        double r389044 = r389040 / r389043;
        double r389045 = r389042 - r389044;
        double r389046 = r389041 / r389045;
        return r389046;
}

double f(double x, double y, double z) {
        double r389047 = x;
        double r389048 = y;
        double r389049 = r389047 + r389048;
        double r389050 = 1.0;
        double r389051 = z;
        double r389052 = r389048 / r389051;
        double r389053 = r389050 - r389052;
        double r389054 = r389049 / r389053;
        double r389055 = -1.8015593186341414e-285;
        bool r389056 = r389054 <= r389055;
        double r389057 = -0.0;
        bool r389058 = r389054 <= r389057;
        double r389059 = !r389058;
        bool r389060 = r389056 || r389059;
        double r389061 = 1.0;
        double r389062 = sqrt(r389050);
        double r389063 = sqrt(r389048);
        double r389064 = sqrt(r389051);
        double r389065 = r389063 / r389064;
        double r389066 = r389062 + r389065;
        double r389067 = r389062 - r389065;
        double r389068 = r389049 / r389067;
        double r389069 = r389066 / r389068;
        double r389070 = r389061 / r389069;
        double r389071 = r389060 ? r389054 : r389070;
        return r389071;
}

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

    1. Initial program 4.3

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

    if -1.8015593186341414e-285 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 56.0

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

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

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

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

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

      \[\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-squares60.8

      \[\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*34.5

      \[\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.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -1.801559318634141379499295463502958423038 \cdot 10^{-285} \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}{\frac{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}{\frac{x + y}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}}\\ \end{array}\]

Reproduce

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