Average Error: 12.2 → 1.9
Time: 14.7s
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 r482645 = x;
        double r482646 = y;
        double r482647 = z;
        double r482648 = r482646 - r482647;
        double r482649 = r482645 * r482648;
        double r482650 = r482649 / r482646;
        return r482650;
}

double f(double x, double y, double z) {
        double r482651 = x;
        double r482652 = y;
        double r482653 = z;
        double r482654 = r482652 - r482653;
        double r482655 = r482651 * r482654;
        double r482656 = r482655 / r482652;
        double r482657 = 2.8425623687727014e-91;
        bool r482658 = r482656 <= r482657;
        double r482659 = r482652 / r482654;
        double r482660 = r482651 / r482659;
        double r482661 = 3.432540453061663e+307;
        bool r482662 = r482656 <= r482661;
        double r482663 = r482651 / r482652;
        double r482664 = r482663 * r482654;
        double r482665 = r482662 ? r482656 : r482664;
        double r482666 = r482658 ? r482660 : r482665;
        return r482666;
}

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