Average Error: 12.4 → 3.5
Time: 3.2s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.2854619819908728 \cdot 10^{-166}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 6.95759694615908471 \cdot 10^{-203}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot \left(y - z\right)\right)\\ \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 -6.2854619819908728 \cdot 10^{-166}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;x \le 6.95759694615908471 \cdot 10^{-203}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot \left(y - z\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r772146 = x;
        double r772147 = y;
        double r772148 = z;
        double r772149 = r772147 - r772148;
        double r772150 = r772146 * r772149;
        double r772151 = r772150 / r772147;
        return r772151;
}

double f(double x, double y, double z) {
        double r772152 = x;
        double r772153 = -6.285461981990873e-166;
        bool r772154 = r772152 <= r772153;
        double r772155 = y;
        double r772156 = z;
        double r772157 = r772155 - r772156;
        double r772158 = r772157 / r772155;
        double r772159 = r772152 * r772158;
        double r772160 = 6.957596946159085e-203;
        bool r772161 = r772152 <= r772160;
        double r772162 = 1.0;
        double r772163 = r772162 / r772155;
        double r772164 = r772152 * r772157;
        double r772165 = r772163 * r772164;
        double r772166 = r772155 / r772157;
        double r772167 = r772166 / r772152;
        double r772168 = r772162 / r772167;
        double r772169 = r772161 ? r772165 : r772168;
        double r772170 = r772154 ? r772159 : r772169;
        return r772170;
}

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.4
Target3.2
Herbie3.5
\[\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 < -6.285461981990873e-166

    1. Initial program 14.2

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

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

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

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

    if -6.285461981990873e-166 < x < 6.957596946159085e-203

    1. Initial program 8.4

      \[\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. Using strategy rm
    5. Applied div-inv7.4

      \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{1}{y - z}}}\]
    6. Applied *-un-lft-identity7.4

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{y \cdot \frac{1}{y - z}}\]
    7. Applied times-frac8.4

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

      \[\leadsto \frac{1}{y} \cdot \color{blue}{\left(x \cdot \left(y - z\right)\right)}\]

    if 6.957596946159085e-203 < x

    1. Initial program 13.1

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied clear-num2.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.2854619819908728 \cdot 10^{-166}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 6.95759694615908471 \cdot 10^{-203}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot \left(y - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{y}{y - z}}{x}}\\ \end{array}\]

Reproduce

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