Average Error: 6.7 → 0.9
Time: 3.4s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \le -5.854653779005750876146040097723722068281 \cdot 10^{293}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \le 1.605413368066265688760018008293374023297 \cdot 10^{299}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{t}}{\frac{1}{z - x}}\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \le -5.854653779005750876146040097723722068281 \cdot 10^{293}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r275342 = x;
        double r275343 = y;
        double r275344 = z;
        double r275345 = r275344 - r275342;
        double r275346 = r275343 * r275345;
        double r275347 = t;
        double r275348 = r275346 / r275347;
        double r275349 = r275342 + r275348;
        return r275349;
}

double f(double x, double y, double z, double t) {
        double r275350 = x;
        double r275351 = y;
        double r275352 = z;
        double r275353 = r275352 - r275350;
        double r275354 = r275351 * r275353;
        double r275355 = t;
        double r275356 = r275354 / r275355;
        double r275357 = r275350 + r275356;
        double r275358 = -5.854653779005751e+293;
        bool r275359 = r275357 <= r275358;
        double r275360 = r275351 / r275355;
        double r275361 = fma(r275360, r275353, r275350);
        double r275362 = 1.6054133680662657e+299;
        bool r275363 = r275357 <= r275362;
        double r275364 = 1.0;
        double r275365 = r275364 / r275353;
        double r275366 = r275360 / r275365;
        double r275367 = r275350 + r275366;
        double r275368 = r275363 ? r275357 : r275367;
        double r275369 = r275359 ? r275361 : r275368;
        return r275369;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (+ x (/ (* y (- z x)) t)) < -5.854653779005751e+293

    1. Initial program 49.2

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

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

    if -5.854653779005751e+293 < (+ x (/ (* y (- z x)) t)) < 1.6054133680662657e+299

    1. Initial program 0.8

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

    if 1.6054133680662657e+299 < (+ x (/ (* y (- z x)) t))

    1. Initial program 52.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \le -5.854653779005750876146040097723722068281 \cdot 10^{293}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \le 1.605413368066265688760018008293374023297 \cdot 10^{299}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{t}}{\frac{1}{z - x}}\\ \end{array}\]

Reproduce

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