Average Error: 6.7 → 1.6
Time: 2.2s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -8.21512428613670165 \cdot 10^{62}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{elif}\;t \le 1.31866975863346645 \cdot 10^{-50}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y - x}{t} \cdot z + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;t \le -8.21512428613670165 \cdot 10^{62}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r477527 = x;
        double r477528 = y;
        double r477529 = r477528 - r477527;
        double r477530 = z;
        double r477531 = r477529 * r477530;
        double r477532 = t;
        double r477533 = r477531 / r477532;
        double r477534 = r477527 + r477533;
        return r477534;
}

double f(double x, double y, double z, double t) {
        double r477535 = t;
        double r477536 = -8.215124286136702e+62;
        bool r477537 = r477535 <= r477536;
        double r477538 = y;
        double r477539 = x;
        double r477540 = r477538 - r477539;
        double r477541 = z;
        double r477542 = r477541 / r477535;
        double r477543 = fma(r477540, r477542, r477539);
        double r477544 = 1.3186697586334664e-50;
        bool r477545 = r477535 <= r477544;
        double r477546 = r477540 * r477541;
        double r477547 = r477546 / r477535;
        double r477548 = r477547 + r477539;
        double r477549 = r477540 / r477535;
        double r477550 = r477549 * r477541;
        double r477551 = r477550 + r477539;
        double r477552 = r477545 ? r477548 : r477551;
        double r477553 = r477537 ? r477543 : r477552;
        return r477553;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target2.1
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;x \lt -9.0255111955330046 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x \lt 4.2750321637007147 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -8.215124286136702e+62

    1. Initial program 11.1

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Simplified1.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef1.3

      \[\leadsto \color{blue}{\frac{y - x}{t} \cdot z + x}\]
    5. Using strategy rm
    6. Applied div-inv1.4

      \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot \frac{1}{t}\right)} \cdot z + x\]
    7. Applied associate-*l*1.3

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(\frac{1}{t} \cdot z\right)} + x\]
    8. Simplified1.3

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{z}{t}} + x\]
    9. Using strategy rm
    10. Applied fma-def1.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)}\]

    if -8.215124286136702e+62 < t < 1.3186697586334664e-50

    1. Initial program 2.1

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Simplified14.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef14.3

      \[\leadsto \color{blue}{\frac{y - x}{t} \cdot z + x}\]
    5. Using strategy rm
    6. Applied div-inv14.4

      \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot \frac{1}{t}\right)} \cdot z + x\]
    7. Applied associate-*l*3.5

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(\frac{1}{t} \cdot z\right)} + x\]
    8. Simplified3.4

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{z}{t}} + x\]
    9. Using strategy rm
    10. Applied associate-*r/2.1

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

    if 1.3186697586334664e-50 < t

    1. Initial program 8.5

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Simplified1.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef1.4

      \[\leadsto \color{blue}{\frac{y - x}{t} \cdot z + x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -8.21512428613670165 \cdot 10^{62}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{elif}\;t \le 1.31866975863346645 \cdot 10^{-50}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y - x}{t} \cdot z + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020065 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

  (+ x (/ (* (- y x) z) t)))