Average Error: 6.5 → 0.4
Time: 2.8s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 1.42845166430598044 \cdot 10^{256}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 1.42845166430598044 \cdot 10^{256}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r282592 = x;
        double r282593 = y;
        double r282594 = z;
        double r282595 = t;
        double r282596 = r282594 - r282595;
        double r282597 = r282593 * r282596;
        double r282598 = a;
        double r282599 = r282597 / r282598;
        double r282600 = r282592 - r282599;
        return r282600;
}

double f(double x, double y, double z, double t, double a) {
        double r282601 = y;
        double r282602 = z;
        double r282603 = t;
        double r282604 = r282602 - r282603;
        double r282605 = r282601 * r282604;
        double r282606 = -inf.0;
        bool r282607 = r282605 <= r282606;
        double r282608 = 1.4284516643059804e+256;
        bool r282609 = r282605 <= r282608;
        double r282610 = !r282609;
        bool r282611 = r282607 || r282610;
        double r282612 = a;
        double r282613 = r282601 / r282612;
        double r282614 = r282603 - r282602;
        double r282615 = x;
        double r282616 = fma(r282613, r282614, r282615);
        double r282617 = r282605 / r282612;
        double r282618 = r282615 - r282617;
        double r282619 = r282611 ? r282616 : r282618;
        return r282619;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.5
Target0.8
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \cdot 10^{-49}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* y (- z t)) < -inf.0 or 1.4284516643059804e+256 < (* y (- z t))

    1. Initial program 50.4

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

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

    if -inf.0 < (* y (- z t)) < 1.4284516643059804e+256

    1. Initial program 0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 1.42845166430598044 \cdot 10^{256}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
  :precision binary64

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

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