Average Error: 6.1 → 0.7
Time: 19.4s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(z - x\right) \cdot y}{t} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \mathbf{elif}\;x + \frac{\left(z - x\right) \cdot y}{t} \le 1.011049397526569 \cdot 10^{+308}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(z - x\right) \cdot y}{t} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r21312271 = x;
        double r21312272 = y;
        double r21312273 = z;
        double r21312274 = r21312273 - r21312271;
        double r21312275 = r21312272 * r21312274;
        double r21312276 = t;
        double r21312277 = r21312275 / r21312276;
        double r21312278 = r21312271 + r21312277;
        return r21312278;
}

double f(double x, double y, double z, double t) {
        double r21312279 = x;
        double r21312280 = z;
        double r21312281 = r21312280 - r21312279;
        double r21312282 = y;
        double r21312283 = r21312281 * r21312282;
        double r21312284 = t;
        double r21312285 = r21312283 / r21312284;
        double r21312286 = r21312279 + r21312285;
        double r21312287 = -inf.0;
        bool r21312288 = r21312286 <= r21312287;
        double r21312289 = r21312281 / r21312284;
        double r21312290 = fma(r21312289, r21312282, r21312279);
        double r21312291 = 1.011049397526569e+308;
        bool r21312292 = r21312286 <= r21312291;
        double r21312293 = r21312292 ? r21312286 : r21312290;
        double r21312294 = r21312288 ? r21312290 : r21312293;
        return r21312294;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target2.0
Herbie0.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 (+ x (/ (* y (- z x)) t)) < -inf.0 or 1.011049397526569e+308 < (+ x (/ (* y (- z x)) t))

    1. Initial program 60.2

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

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

    if -inf.0 < (+ x (/ (* y (- z x)) t)) < 1.011049397526569e+308

    1. Initial program 0.8

      \[x + \frac{y \cdot \left(z - x\right)}{t}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

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

Reproduce

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

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

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