Average Error: 6.4 → 1.7
Time: 2.9s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.121711157699570129271913673205635143014 \cdot 10^{83}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \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}\;y \le -2.121711157699570129271913673205635143014 \cdot 10^{83}:\\
\;\;\;\;y \cdot \frac{z - x}{t} + x\\

\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 r281189 = x;
        double r281190 = y;
        double r281191 = z;
        double r281192 = r281191 - r281189;
        double r281193 = r281190 * r281192;
        double r281194 = t;
        double r281195 = r281193 / r281194;
        double r281196 = r281189 + r281195;
        return r281196;
}

double f(double x, double y, double z, double t) {
        double r281197 = y;
        double r281198 = -2.12171115769957e+83;
        bool r281199 = r281197 <= r281198;
        double r281200 = z;
        double r281201 = x;
        double r281202 = r281200 - r281201;
        double r281203 = t;
        double r281204 = r281202 / r281203;
        double r281205 = r281197 * r281204;
        double r281206 = r281205 + r281201;
        double r281207 = r281197 / r281203;
        double r281208 = fma(r281207, r281202, r281201);
        double r281209 = r281199 ? r281206 : r281208;
        return r281209;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 2 regimes
  2. if y < -2.12171115769957e+83

    1. Initial program 22.0

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

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

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

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

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

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

    if -2.12171115769957e+83 < y

    1. Initial program 4.3

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

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

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

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

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

Reproduce

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