Average Error: 11.7 → 3.1
Time: 7.0s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -7.326181763082673 \cdot 10^{-13}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;y \le 2.6779333906407255 \cdot 10^{-232}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \le -7.326181763082673 \cdot 10^{-13}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;y \le 2.6779333906407255 \cdot 10^{-232}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r14452557 = x;
        double r14452558 = y;
        double r14452559 = z;
        double r14452560 = r14452558 - r14452559;
        double r14452561 = r14452557 * r14452560;
        double r14452562 = r14452561 / r14452558;
        return r14452562;
}

double f(double x, double y, double z) {
        double r14452563 = y;
        double r14452564 = -7.326181763082673e-13;
        bool r14452565 = r14452563 <= r14452564;
        double r14452566 = x;
        double r14452567 = z;
        double r14452568 = r14452563 - r14452567;
        double r14452569 = r14452568 / r14452563;
        double r14452570 = r14452566 * r14452569;
        double r14452571 = 2.6779333906407255e-232;
        bool r14452572 = r14452563 <= r14452571;
        double r14452573 = r14452566 / r14452563;
        double r14452574 = 1.0;
        double r14452575 = r14452574 / r14452568;
        double r14452576 = r14452573 / r14452575;
        double r14452577 = r14452563 / r14452568;
        double r14452578 = r14452566 / r14452577;
        double r14452579 = r14452572 ? r14452576 : r14452578;
        double r14452580 = r14452565 ? r14452570 : r14452579;
        return r14452580;
}

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.7
Target3.2
Herbie3.1
\[\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 < -7.326181763082673e-13

    1. Initial program 14.4

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

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

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

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

    if -7.326181763082673e-13 < y < 2.6779333906407255e-232

    1. Initial program 8.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 div-inv8.7

      \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{1}{y - z}}}\]
    6. Applied associate-/r*8.9

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

    if 2.6779333906407255e-232 < y

    1. Initial program 11.9

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

      \[\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}\;y \le -7.326181763082673 \cdot 10^{-13}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;y \le 2.6779333906407255 \cdot 10^{-232}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]

Reproduce

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