Average Error: 6.3 → 1.3
Time: 13.3s
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 -1.12539201893726255 \cdot 10^{306}:\\ \;\;\;\;\frac{z - x}{\frac{t}{y}} + x\\ \mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \le -5.52428703018855934 \cdot 10^{-210}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \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 -1.12539201893726255 \cdot 10^{306}:\\
\;\;\;\;\frac{z - x}{\frac{t}{y}} + x\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r286322 = x;
        double r286323 = y;
        double r286324 = z;
        double r286325 = r286324 - r286322;
        double r286326 = r286323 * r286325;
        double r286327 = t;
        double r286328 = r286326 / r286327;
        double r286329 = r286322 + r286328;
        return r286329;
}

double f(double x, double y, double z, double t) {
        double r286330 = x;
        double r286331 = y;
        double r286332 = z;
        double r286333 = r286332 - r286330;
        double r286334 = r286331 * r286333;
        double r286335 = t;
        double r286336 = r286334 / r286335;
        double r286337 = r286330 + r286336;
        double r286338 = -1.1253920189372625e+306;
        bool r286339 = r286337 <= r286338;
        double r286340 = r286335 / r286331;
        double r286341 = r286333 / r286340;
        double r286342 = r286341 + r286330;
        double r286343 = -5.5242870301885593e-210;
        bool r286344 = r286337 <= r286343;
        double r286345 = r286331 / r286335;
        double r286346 = fma(r286345, r286333, r286330);
        double r286347 = r286344 ? r286337 : r286346;
        double r286348 = r286339 ? r286342 : r286347;
        return r286348;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.3
Target2.0
Herbie1.3
\[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)) < -1.1253920189372625e+306

    1. Initial program 61.5

      \[x + \frac{y \cdot \left(z - x\right)}{t}\]
    2. Using strategy rm
    3. Applied div-inv61.5

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

      \[\leadsto x + \left(y \cdot \left(z - x\right)\right) \cdot \color{blue}{{\left(\frac{1}{t}\right)}^{1}}\]
    6. Applied pow161.5

      \[\leadsto x + \left(y \cdot \color{blue}{{\left(z - x\right)}^{1}}\right) \cdot {\left(\frac{1}{t}\right)}^{1}\]
    7. Applied pow161.5

      \[\leadsto x + \left(\color{blue}{{y}^{1}} \cdot {\left(z - x\right)}^{1}\right) \cdot {\left(\frac{1}{t}\right)}^{1}\]
    8. Applied pow-prod-down61.5

      \[\leadsto x + \color{blue}{{\left(y \cdot \left(z - x\right)\right)}^{1}} \cdot {\left(\frac{1}{t}\right)}^{1}\]
    9. Applied pow-prod-down61.5

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

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

    if -1.1253920189372625e+306 < (+ x (/ (* y (- z x)) t)) < -5.5242870301885593e-210

    1. Initial program 0.3

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

    if -5.5242870301885593e-210 < (+ x (/ (* y (- z x)) t))

    1. Initial program 6.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.3

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

Reproduce

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