Average Error: 12.7 → 0.7
Time: 10.3s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} = -\infty:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le -7.035752593527431893945155653212148797057 \cdot 10^{97}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 2.566980890461996323345451498436663106865 \cdot 10^{-126}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 3.205146683618994452349289842865450278396 \cdot 10^{270}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} = -\infty:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

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

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

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

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

\end{array}
double f(double x, double y, double z) {
        double r855509 = x;
        double r855510 = y;
        double r855511 = z;
        double r855512 = r855510 - r855511;
        double r855513 = r855509 * r855512;
        double r855514 = r855513 / r855510;
        return r855514;
}

double f(double x, double y, double z) {
        double r855515 = x;
        double r855516 = y;
        double r855517 = z;
        double r855518 = r855516 - r855517;
        double r855519 = r855515 * r855518;
        double r855520 = r855519 / r855516;
        double r855521 = -inf.0;
        bool r855522 = r855520 <= r855521;
        double r855523 = r855516 / r855518;
        double r855524 = r855515 / r855523;
        double r855525 = -7.035752593527432e+97;
        bool r855526 = r855520 <= r855525;
        double r855527 = 2.5669808904619963e-126;
        bool r855528 = r855520 <= r855527;
        double r855529 = 3.2051466836189945e+270;
        bool r855530 = r855520 <= r855529;
        double r855531 = r855518 / r855516;
        double r855532 = r855515 * r855531;
        double r855533 = r855530 ? r855520 : r855532;
        double r855534 = r855528 ? r855524 : r855533;
        double r855535 = r855526 ? r855520 : r855534;
        double r855536 = r855522 ? r855524 : r855535;
        return r855536;
}

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.7
Target3.2
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739024383612783691266533098 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.693976601382852594702773997610248441465 \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 (- y z)) y) < -inf.0 or -7.035752593527432e+97 < (/ (* x (- y z)) y) < 2.5669808904619963e-126

    1. Initial program 16.2

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

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

    if -inf.0 < (/ (* x (- y z)) y) < -7.035752593527432e+97 or 2.5669808904619963e-126 < (/ (* x (- y z)) y) < 3.2051466836189945e+270

    1. Initial program 0.3

      \[\frac{x \cdot \left(y - z\right)}{y}\]

    if 3.2051466836189945e+270 < (/ (* x (- y z)) y)

    1. Initial program 49.5

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{y}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} = -\infty:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le -7.035752593527431893945155653212148797057 \cdot 10^{97}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 2.566980890461996323345451498436663106865 \cdot 10^{-126}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 3.205146683618994452349289842865450278396 \cdot 10^{270}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]

Reproduce

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