Average Error: 12.1 → 3.1
Time: 2.1s
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 r628748 = x;
        double r628749 = y;
        double r628750 = z;
        double r628751 = r628749 - r628750;
        double r628752 = r628748 * r628751;
        double r628753 = r628752 / r628749;
        return r628753;
}

double f(double x, double y, double z) {
        double r628754 = x;
        double r628755 = -5.0032800548876926e-101;
        bool r628756 = r628754 <= r628755;
        double r628757 = y;
        double r628758 = z;
        double r628759 = r628757 - r628758;
        double r628760 = r628759 / r628757;
        double r628761 = r628754 * r628760;
        double r628762 = 5.758281187392746e-300;
        bool r628763 = r628754 <= r628762;
        double r628764 = 1.0;
        double r628765 = r628764 / r628757;
        double r628766 = r628754 * r628759;
        double r628767 = r628765 * r628766;
        double r628768 = r628757 / r628759;
        double r628769 = r628754 / r628768;
        double r628770 = r628763 ? r628767 : r628769;
        double r628771 = r628756 ? r628761 : r628770;
        return r628771;
}

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