Average Error: 11.4 → 3.0
Time: 13.5s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -5.854341452353873 \cdot 10^{-96}:\\ \;\;\;\;\frac{x}{\frac{1}{y - z} \cdot y}\\ \mathbf{elif}\;y \le 6.662421720446094 \cdot 10^{-114}:\\ \;\;\;\;\frac{\left(-x \cdot z\right) + x \cdot y}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \le -5.854341452353873 \cdot 10^{-96}:\\
\;\;\;\;\frac{x}{\frac{1}{y - z} \cdot y}\\

\mathbf{elif}\;y \le 6.662421720446094 \cdot 10^{-114}:\\
\;\;\;\;\frac{\left(-x \cdot z\right) + x \cdot y}{y}\\

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

\end{array}
double f(double x, double y, double z) {
        double r25670729 = x;
        double r25670730 = y;
        double r25670731 = z;
        double r25670732 = r25670730 - r25670731;
        double r25670733 = r25670729 * r25670732;
        double r25670734 = r25670733 / r25670730;
        return r25670734;
}

double f(double x, double y, double z) {
        double r25670735 = y;
        double r25670736 = -5.854341452353873e-96;
        bool r25670737 = r25670735 <= r25670736;
        double r25670738 = x;
        double r25670739 = 1.0;
        double r25670740 = z;
        double r25670741 = r25670735 - r25670740;
        double r25670742 = r25670739 / r25670741;
        double r25670743 = r25670742 * r25670735;
        double r25670744 = r25670738 / r25670743;
        double r25670745 = 6.662421720446094e-114;
        bool r25670746 = r25670735 <= r25670745;
        double r25670747 = r25670738 * r25670740;
        double r25670748 = -r25670747;
        double r25670749 = r25670738 * r25670735;
        double r25670750 = r25670748 + r25670749;
        double r25670751 = r25670750 / r25670735;
        double r25670752 = r25670741 / r25670735;
        double r25670753 = r25670738 * r25670752;
        double r25670754 = r25670746 ? r25670751 : r25670753;
        double r25670755 = r25670737 ? r25670744 : r25670754;
        return r25670755;
}

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

Original11.4
Target2.8
Herbie3.0
\[\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 3 regimes
  2. if y < -5.854341452353873e-96

    1. Initial program 12.5

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied div-inv0.5

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

    if -5.854341452353873e-96 < y < 6.662421720446094e-114

    1. Initial program 9.2

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied sub-neg9.2

      \[\leadsto \frac{x \cdot \color{blue}{\left(y + \left(-z\right)\right)}}{y}\]
    4. Applied distribute-rgt-in9.2

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

    if 6.662421720446094e-114 < y

    1. Initial program 11.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -5.854341452353873 \cdot 10^{-96}:\\ \;\;\;\;\frac{x}{\frac{1}{y - z} \cdot y}\\ \mathbf{elif}\;y \le 6.662421720446094 \cdot 10^{-114}:\\ \;\;\;\;\frac{\left(-x \cdot z\right) + x \cdot y}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]

Reproduce

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