Average Error: 12.3 → 2.6
Time: 15.7s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.3817440569525898 \cdot 10^{-289}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 4.0099369996684946 \cdot 10^{-103}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le 1.3817440569525898 \cdot 10^{-289}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r40823394 = x;
        double r40823395 = y;
        double r40823396 = z;
        double r40823397 = r40823395 - r40823396;
        double r40823398 = r40823394 * r40823397;
        double r40823399 = r40823398 / r40823395;
        return r40823399;
}

double f(double x, double y, double z) {
        double r40823400 = x;
        double r40823401 = 1.3817440569525898e-289;
        bool r40823402 = r40823400 <= r40823401;
        double r40823403 = y;
        double r40823404 = z;
        double r40823405 = r40823403 - r40823404;
        double r40823406 = r40823405 / r40823403;
        double r40823407 = r40823400 * r40823406;
        double r40823408 = 4.0099369996684946e-103;
        bool r40823409 = r40823400 <= r40823408;
        double r40823410 = r40823404 * r40823400;
        double r40823411 = r40823410 / r40823403;
        double r40823412 = r40823400 - r40823411;
        double r40823413 = r40823409 ? r40823412 : r40823407;
        double r40823414 = r40823402 ? r40823407 : r40823413;
        return r40823414;
}

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.3
Target2.8
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.6939766013828526 \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 2 regimes
  2. if x < 1.3817440569525898e-289 or 4.0099369996684946e-103 < x

    1. Initial program 13.5

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

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

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

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

    if 1.3817440569525898e-289 < x < 4.0099369996684946e-103

    1. Initial program 6.2

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{y}\]
    6. Taylor expanded around 0 3.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.3817440569525898 \cdot 10^{-289}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 4.0099369996684946 \cdot 10^{-103}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]

Reproduce

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

  :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))