Average Error: 7.3 → 0.2
Time: 21.0s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;y \le -15383809086552125997056 \lor \neg \left(y \le 2.211156237826685988742868005409983379368 \cdot 10^{49}\right):\\ \;\;\;\;\frac{1}{\frac{1}{y + x} - \frac{\frac{y}{y + x}}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;y \le -15383809086552125997056 \lor \neg \left(y \le 2.211156237826685988742868005409983379368 \cdot 10^{49}\right):\\
\;\;\;\;\frac{1}{\frac{1}{y + x} - \frac{\frac{y}{y + x}}{z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r412855 = x;
        double r412856 = y;
        double r412857 = r412855 + r412856;
        double r412858 = 1.0;
        double r412859 = z;
        double r412860 = r412856 / r412859;
        double r412861 = r412858 - r412860;
        double r412862 = r412857 / r412861;
        return r412862;
}

double f(double x, double y, double z) {
        double r412863 = y;
        double r412864 = -1.5383809086552126e+22;
        bool r412865 = r412863 <= r412864;
        double r412866 = 2.211156237826686e+49;
        bool r412867 = r412863 <= r412866;
        double r412868 = !r412867;
        bool r412869 = r412865 || r412868;
        double r412870 = 1.0;
        double r412871 = 1.0;
        double r412872 = x;
        double r412873 = r412863 + r412872;
        double r412874 = r412871 / r412873;
        double r412875 = r412863 / r412873;
        double r412876 = z;
        double r412877 = r412875 / r412876;
        double r412878 = r412874 - r412877;
        double r412879 = r412870 / r412878;
        double r412880 = r412872 + r412863;
        double r412881 = r412863 / r412876;
        double r412882 = r412871 - r412881;
        double r412883 = r412880 / r412882;
        double r412884 = r412869 ? r412879 : r412883;
        return r412884;
}

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.3
Target3.9
Herbie0.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 y < -1.5383809086552126e+22 or 2.211156237826686e+49 < y

    1. Initial program 16.3

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}}\]
    4. Using strategy rm
    5. Applied div-sub16.4

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{x + y} - \frac{\frac{y}{z}}{x + y}}}\]
    6. Simplified16.4

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{y + x}} - \frac{\frac{y}{z}}{x + y}}\]
    7. Simplified0.2

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

    if -1.5383809086552126e+22 < y < 2.211156237826686e+49

    1. Initial program 0.2

      \[\frac{x + y}{1 - \frac{y}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

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

Reproduce

herbie shell --seed 2019306 +o rules:numerics
(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))))