Average Error: 12.9 → 3.3
Time: 2.0s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.3574032127967498 \cdot 10^{63}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \le 1.3574032127967498 \cdot 10^{63}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

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

\end{array}
double f(double x, double y, double z) {
        double r778566 = x;
        double r778567 = y;
        double r778568 = z;
        double r778569 = r778567 - r778568;
        double r778570 = r778566 * r778569;
        double r778571 = r778570 / r778567;
        return r778571;
}

double f(double x, double y, double z) {
        double r778572 = y;
        double r778573 = 1.3574032127967498e+63;
        bool r778574 = r778572 <= r778573;
        double r778575 = x;
        double r778576 = z;
        double r778577 = r778575 * r778576;
        double r778578 = r778577 / r778572;
        double r778579 = r778575 - r778578;
        double r778580 = r778576 / r778572;
        double r778581 = r778575 * r778580;
        double r778582 = r778575 - r778581;
        double r778583 = r778574 ? r778579 : r778582;
        return r778583;
}

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.9
Target3.0
Herbie3.3
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.69397660138285259 \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 2 regimes
  2. if y < 1.3574032127967498e+63

    1. Initial program 10.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 4.3

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

    if 1.3574032127967498e+63 < y

    1. Initial program 20.5

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 6.9

      \[\leadsto \color{blue}{x - \frac{x \cdot z}{y}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity6.9

      \[\leadsto x - \frac{x \cdot z}{\color{blue}{1 \cdot y}}\]
    7. Applied times-frac0.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 1.3574032127967498 \cdot 10^{63}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array}\]

Reproduce

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