Average Error: 12.2 → 1.9
Time: 12.1s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le 2.842562368772701429645805907300691455493 \cdot 10^{-91}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 3.432540453061663231003216489606318759457 \cdot 10^{307}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le 2.842562368772701429645805907300691455493 \cdot 10^{-91}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\

\end{array}
double f(double x, double y, double z) {
        double r500391 = x;
        double r500392 = y;
        double r500393 = z;
        double r500394 = r500392 - r500393;
        double r500395 = r500391 * r500394;
        double r500396 = r500395 / r500392;
        return r500396;
}

double f(double x, double y, double z) {
        double r500397 = x;
        double r500398 = y;
        double r500399 = z;
        double r500400 = r500398 - r500399;
        double r500401 = r500397 * r500400;
        double r500402 = r500401 / r500398;
        double r500403 = 2.8425623687727014e-91;
        bool r500404 = r500402 <= r500403;
        double r500405 = r500398 / r500400;
        double r500406 = r500397 / r500405;
        double r500407 = 3.432540453061663e+307;
        bool r500408 = r500402 <= r500407;
        double r500409 = r500397 / r500398;
        double r500410 = r500409 * r500400;
        double r500411 = r500408 ? r500402 : r500410;
        double r500412 = r500404 ? r500406 : r500411;
        return r500412;
}

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.2
Target3.3
Herbie1.9
\[\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) < 2.8425623687727014e-91

    1. Initial program 11.2

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

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

    if 2.8425623687727014e-91 < (/ (* x (- y z)) y) < 3.432540453061663e+307

    1. Initial program 0.3

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

    if 3.432540453061663e+307 < (/ (* x (- y z)) y)

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.1

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le 2.842562368772701429645805907300691455493 \cdot 10^{-91}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 3.432540453061663231003216489606318759457 \cdot 10^{307}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\ \end{array}\]

Reproduce

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