Average Error: 12.0 → 2.6
Time: 10.8s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.727842335792455 \cdot 10^{-115}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 6.94029728708334437 \cdot 10^{-305}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{y}{y - z}}{x}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le -4.727842335792455 \cdot 10^{-115}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;x \le 6.94029728708334437 \cdot 10^{-305}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

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

\end{array}
double f(double x, double y, double z) {
        double r789886 = x;
        double r789887 = y;
        double r789888 = z;
        double r789889 = r789887 - r789888;
        double r789890 = r789886 * r789889;
        double r789891 = r789890 / r789887;
        return r789891;
}

double f(double x, double y, double z) {
        double r789892 = x;
        double r789893 = -4.727842335792455e-115;
        bool r789894 = r789892 <= r789893;
        double r789895 = y;
        double r789896 = z;
        double r789897 = r789895 - r789896;
        double r789898 = r789897 / r789895;
        double r789899 = r789892 * r789898;
        double r789900 = 6.940297287083344e-305;
        bool r789901 = r789892 <= r789900;
        double r789902 = r789892 * r789896;
        double r789903 = r789902 / r789895;
        double r789904 = r789892 - r789903;
        double r789905 = 1.0;
        double r789906 = r789895 / r789897;
        double r789907 = r789906 / r789892;
        double r789908 = r789905 / r789907;
        double r789909 = r789901 ? r789904 : r789908;
        double r789910 = r789894 ? r789899 : r789909;
        return r789910;
}

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

Original12.0
Target3.3
Herbie2.6
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.69397660138285259 \cdot 10^{213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -4.727842335792455e-115

    1. Initial program 14.6

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity14.6

      \[\leadsto \frac{x \cdot \left(y - z\right)}{\color{blue}{1 \cdot y}}\]
    4. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y - z}{y}}\]
    5. Simplified0.9

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

    if -4.727842335792455e-115 < x < 6.940297287083344e-305

    1. Initial program 7.2

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*7.3

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 4.0

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

    if 6.940297287083344e-305 < x

    1. Initial program 12.1

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*3.0

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

      \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{1}{y - z}}}\]
    6. Using strategy rm
    7. Applied clear-num3.2

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot \frac{1}{y - z}}{x}}}\]
    8. Simplified3.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.727842335792455 \cdot 10^{-115}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 6.94029728708334437 \cdot 10^{-305}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{y}{y - z}}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

  (/ (* x (- y z)) y))