Average Error: 6.1 → 2.3
Time: 5.8s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \le 2.7473712769312009 \cdot 10^{-146}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;y \le 3.65776030122223192 \cdot 10^{289}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -x \cdot 1\right) \cdot \frac{y}{t} + \mathsf{fma}\left(\mathsf{fma}\left(-x, 1, x\right), \frac{y}{t}, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;y \le 2.7473712769312009 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

\mathbf{elif}\;y \le 3.65776030122223192 \cdot 10^{289}:\\
\;\;\;\;y \cdot \frac{z - x}{t} + x\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -x \cdot 1\right) \cdot \frac{y}{t} + \mathsf{fma}\left(\mathsf{fma}\left(-x, 1, x\right), \frac{y}{t}, x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r288296 = x;
        double r288297 = y;
        double r288298 = z;
        double r288299 = r288298 - r288296;
        double r288300 = r288297 * r288299;
        double r288301 = t;
        double r288302 = r288300 / r288301;
        double r288303 = r288296 + r288302;
        return r288303;
}

double f(double x, double y, double z, double t) {
        double r288304 = y;
        double r288305 = 2.747371276931201e-146;
        bool r288306 = r288304 <= r288305;
        double r288307 = t;
        double r288308 = r288304 / r288307;
        double r288309 = z;
        double r288310 = x;
        double r288311 = r288309 - r288310;
        double r288312 = fma(r288308, r288311, r288310);
        double r288313 = 3.657760301222232e+289;
        bool r288314 = r288304 <= r288313;
        double r288315 = r288311 / r288307;
        double r288316 = r288304 * r288315;
        double r288317 = r288316 + r288310;
        double r288318 = cbrt(r288309);
        double r288319 = r288318 * r288318;
        double r288320 = 1.0;
        double r288321 = r288310 * r288320;
        double r288322 = -r288321;
        double r288323 = fma(r288319, r288318, r288322);
        double r288324 = r288323 * r288308;
        double r288325 = -r288310;
        double r288326 = fma(r288325, r288320, r288310);
        double r288327 = fma(r288326, r288308, r288310);
        double r288328 = r288324 + r288327;
        double r288329 = r288314 ? r288317 : r288328;
        double r288330 = r288306 ? r288312 : r288329;
        return r288330;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target2.0
Herbie2.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 y < 2.747371276931201e-146

    1. Initial program 4.6

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

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

    if 2.747371276931201e-146 < y < 3.657760301222232e+289

    1. Initial program 8.7

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

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

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

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

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

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

    if 3.657760301222232e+289 < y

    1. Initial program 35.0

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

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

      \[\leadsto \color{blue}{\frac{y}{t} \cdot \left(z - x\right) + x}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity9.9

      \[\leadsto \frac{y}{t} \cdot \left(z - \color{blue}{1 \cdot x}\right) + x\]
    7. Applied add-cube-cbrt10.3

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

      \[\leadsto \frac{y}{t} \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -x \cdot 1\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)\right)} + x\]
    9. Applied distribute-rgt-in10.3

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -x \cdot 1\right) \cdot \frac{y}{t} + \mathsf{fma}\left(-x, 1, x \cdot 1\right) \cdot \frac{y}{t}\right)} + x\]
    10. Applied associate-+l+10.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -x \cdot 1\right) \cdot \frac{y}{t} + \left(\mathsf{fma}\left(-x, 1, x \cdot 1\right) \cdot \frac{y}{t} + x\right)}\]
    11. Simplified10.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 2.7473712769312009 \cdot 10^{-146}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;y \le 3.65776030122223192 \cdot 10^{289}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -x \cdot 1\right) \cdot \frac{y}{t} + \mathsf{fma}\left(\mathsf{fma}\left(-x, 1, x\right), \frac{y}{t}, x\right)\\ \end{array}\]

Reproduce

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