Average Error: 6.7 → 2.1
Time: 4.3s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.45494683705326644 \cdot 10^{-300} \lor \neg \left(x \le 5.69376695784929436 \cdot 10^{-84}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \le 1.45494683705326644 \cdot 10^{-300} \lor \neg \left(x \le 5.69376695784929436 \cdot 10^{-84}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r316316 = x;
        double r316317 = y;
        double r316318 = z;
        double r316319 = r316318 - r316316;
        double r316320 = r316317 * r316319;
        double r316321 = t;
        double r316322 = r316320 / r316321;
        double r316323 = r316316 + r316322;
        return r316323;
}

double f(double x, double y, double z, double t) {
        double r316324 = x;
        double r316325 = 1.4549468370532664e-300;
        bool r316326 = r316324 <= r316325;
        double r316327 = 5.693766957849294e-84;
        bool r316328 = r316324 <= r316327;
        double r316329 = !r316328;
        bool r316330 = r316326 || r316329;
        double r316331 = y;
        double r316332 = t;
        double r316333 = r316331 / r316332;
        double r316334 = z;
        double r316335 = r316334 - r316324;
        double r316336 = fma(r316333, r316335, r316324);
        double r316337 = r316335 / r316332;
        double r316338 = r316331 * r316337;
        double r316339 = r316338 + r316324;
        double r316340 = r316330 ? r316336 : r316339;
        return r316340;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target2.0
Herbie2.1
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 1.4549468370532664e-300 or 5.693766957849294e-84 < x

    1. Initial program 7.0

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

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

    if 1.4549468370532664e-300 < x < 5.693766957849294e-84

    1. Initial program 5.5

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.45494683705326644 \cdot 10^{-300} \lor \neg \left(x \le 5.69376695784929436 \cdot 10^{-84}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

  :herbie-target
  (- x (+ (* x (/ y t)) (* (- z) (/ y t))))

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