Average Error: 12.1 → 3.1
Time: 2.2s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.003280054887692628318180433391057882342 \cdot 10^{-101}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 5.758281187392745987255992146907159625285 \cdot 10^{-300}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot \left(y - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le -5.003280054887692628318180433391057882342 \cdot 10^{-101}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r873397 = x;
        double r873398 = y;
        double r873399 = z;
        double r873400 = r873398 - r873399;
        double r873401 = r873397 * r873400;
        double r873402 = r873401 / r873398;
        return r873402;
}

double f(double x, double y, double z) {
        double r873403 = x;
        double r873404 = -5.0032800548876926e-101;
        bool r873405 = r873403 <= r873404;
        double r873406 = y;
        double r873407 = z;
        double r873408 = r873406 - r873407;
        double r873409 = r873408 / r873406;
        double r873410 = r873403 * r873409;
        double r873411 = 5.758281187392746e-300;
        bool r873412 = r873403 <= r873411;
        double r873413 = 1.0;
        double r873414 = r873413 / r873406;
        double r873415 = r873403 * r873408;
        double r873416 = r873414 * r873415;
        double r873417 = r873406 / r873408;
        double r873418 = r873403 / r873417;
        double r873419 = r873412 ? r873416 : r873418;
        double r873420 = r873405 ? r873410 : r873419;
        return r873420;
}

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.1
Target2.9
Herbie3.1
\[\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 < -5.0032800548876926e-101

    1. Initial program 15.2

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

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

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

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

    if -5.0032800548876926e-101 < x < 5.758281187392746e-300

    1. Initial program 7.4

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

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

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

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

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

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

    if 5.758281187392746e-300 < x

    1. Initial program 12.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.003280054887692628318180433391057882342 \cdot 10^{-101}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 5.758281187392745987255992146907159625285 \cdot 10^{-300}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot \left(y - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]

Reproduce

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