Average Error: 7.2 → 5.9
Time: 19.6s
Precision: 64
\[\frac{x + y}{1.0 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -2.5200352144339976 \cdot 10^{-283}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \mathbf{elif}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -0.0:\\ \;\;\;\;\frac{\frac{\sqrt{y + x}}{\sqrt{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\sqrt{y + x}}{\sqrt{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}}}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1.0 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{y + x}{1.0 - \frac{y}{z}} \le -2.5200352144339976 \cdot 10^{-283}:\\
\;\;\;\;\frac{y + x}{1.0 - \frac{y}{z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r27829025 = x;
        double r27829026 = y;
        double r27829027 = r27829025 + r27829026;
        double r27829028 = 1.0;
        double r27829029 = z;
        double r27829030 = r27829026 / r27829029;
        double r27829031 = r27829028 - r27829030;
        double r27829032 = r27829027 / r27829031;
        return r27829032;
}

double f(double x, double y, double z) {
        double r27829033 = y;
        double r27829034 = x;
        double r27829035 = r27829033 + r27829034;
        double r27829036 = 1.0;
        double r27829037 = z;
        double r27829038 = r27829033 / r27829037;
        double r27829039 = r27829036 - r27829038;
        double r27829040 = r27829035 / r27829039;
        double r27829041 = -2.5200352144339976e-283;
        bool r27829042 = r27829040 <= r27829041;
        double r27829043 = -0.0;
        bool r27829044 = r27829040 <= r27829043;
        double r27829045 = sqrt(r27829035);
        double r27829046 = sqrt(r27829036);
        double r27829047 = sqrt(r27829033);
        double r27829048 = sqrt(r27829037);
        double r27829049 = r27829047 / r27829048;
        double r27829050 = r27829046 + r27829049;
        double r27829051 = sqrt(r27829050);
        double r27829052 = r27829045 / r27829051;
        double r27829053 = r27829052 * r27829052;
        double r27829054 = r27829046 - r27829049;
        double r27829055 = r27829053 / r27829054;
        double r27829056 = r27829044 ? r27829055 : r27829040;
        double r27829057 = r27829042 ? r27829040 : r27829056;
        return r27829057;
}

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.0
Herbie5.9
\[\begin{array}{l} \mathbf{if}\;y \lt -3.7429310762689856 \cdot 10^{+171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.5534662456086734 \cdot 10^{+168}:\\ \;\;\;\;\frac{x + y}{1.0 - \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))) < -2.5200352144339976e-283 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

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

    if -2.5200352144339976e-283 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 58.9

      \[\frac{x + y}{1.0 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt60.5

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

      \[\leadsto \frac{x + y}{1.0 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    5. Applied times-frac61.7

      \[\leadsto \frac{x + y}{1.0 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    6. Applied add-sqr-sqrt61.7

      \[\leadsto \frac{x + y}{\color{blue}{\sqrt{1.0} \cdot \sqrt{1.0}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    7. Applied difference-of-squares61.7

      \[\leadsto \frac{x + y}{\color{blue}{\left(\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    8. Applied associate-/r*46.7

      \[\leadsto \color{blue}{\frac{\frac{x + y}{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt46.7

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

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{x + y} \cdot \sqrt{x + y}}}{\sqrt{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \sqrt{\sqrt{1.0} + \frac{\sqrt{y}}{\sqrt{z}}}}}{\sqrt{1.0} - \frac{\sqrt{y}}{\sqrt{z}}}\]
    12. Applied times-frac47.8

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

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

Reproduce

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