Average Error: 12.2 → 1.9
Time: 12.8s
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 r681732 = x;
        double r681733 = y;
        double r681734 = z;
        double r681735 = r681733 - r681734;
        double r681736 = r681732 * r681735;
        double r681737 = r681736 / r681733;
        return r681737;
}

double f(double x, double y, double z) {
        double r681738 = x;
        double r681739 = y;
        double r681740 = z;
        double r681741 = r681739 - r681740;
        double r681742 = r681738 * r681741;
        double r681743 = r681742 / r681739;
        double r681744 = 2.8425623687727014e-91;
        bool r681745 = r681743 <= r681744;
        double r681746 = r681739 / r681741;
        double r681747 = r681738 / r681746;
        double r681748 = 3.432540453061663e+307;
        bool r681749 = r681743 <= r681748;
        double r681750 = r681738 / r681739;
        double r681751 = r681750 * r681741;
        double r681752 = r681749 ? r681743 : r681751;
        double r681753 = r681745 ? r681747 : r681752;
        return r681753;
}

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