Average Error: 12.2 → 3.5
Time: 2.4s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.566982273345146481292091546063448334105 \cdot 10^{71}:\\ \;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 \cdot \left(1 - \frac{z}{y}\right)\right)\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;z \le -1.566982273345146481292091546063448334105 \cdot 10^{71}:\\
\;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r775327 = x;
        double r775328 = y;
        double r775329 = z;
        double r775330 = r775328 - r775329;
        double r775331 = r775327 * r775330;
        double r775332 = r775331 / r775328;
        return r775332;
}

double f(double x, double y, double z) {
        double r775333 = z;
        double r775334 = -1.5669822733451465e+71;
        bool r775335 = r775333 <= r775334;
        double r775336 = x;
        double r775337 = y;
        double r775338 = r775336 / r775337;
        double r775339 = r775337 - r775333;
        double r775340 = r775338 * r775339;
        double r775341 = 1.0;
        double r775342 = r775333 / r775337;
        double r775343 = r775341 - r775342;
        double r775344 = r775341 * r775343;
        double r775345 = r775336 * r775344;
        double r775346 = r775335 ? r775340 : r775345;
        return r775346;
}

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.0
Herbie3.5
\[\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 2 regimes
  2. if z < -1.5669822733451465e+71

    1. Initial program 12.1

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

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

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

    if -1.5669822733451465e+71 < z

    1. Initial program 12.3

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{y}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity2.0

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

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

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

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

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

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

Reproduce

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