Average Error: 6.5 → 0.3
Time: 3.2s
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.9771523914851648 \cdot 10^{226}\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.9771523914851648 \cdot 10^{226}\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 r279170 = x;
        double r279171 = y;
        double r279172 = z;
        double r279173 = t;
        double r279174 = r279172 - r279173;
        double r279175 = r279171 * r279174;
        double r279176 = a;
        double r279177 = r279175 / r279176;
        double r279178 = r279170 - r279177;
        return r279178;
}

double f(double x, double y, double z, double t, double a) {
        double r279179 = y;
        double r279180 = z;
        double r279181 = t;
        double r279182 = r279180 - r279181;
        double r279183 = r279179 * r279182;
        double r279184 = -inf.0;
        bool r279185 = r279183 <= r279184;
        double r279186 = 1.9771523914851648e+226;
        bool r279187 = r279183 <= r279186;
        double r279188 = !r279187;
        bool r279189 = r279185 || r279188;
        double r279190 = a;
        double r279191 = r279179 / r279190;
        double r279192 = r279181 - r279180;
        double r279193 = x;
        double r279194 = fma(r279191, r279192, r279193);
        double r279195 = r279183 / r279190;
        double r279196 = r279193 - r279195;
        double r279197 = r279189 ? r279194 : r279196;
        return r279197;
}

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.7
Herbie0.3
\[\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.9771523914851648e+226 < (* y (- z t))

    1. Initial program 43.7

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

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

    if -inf.0 < (* y (- z t)) < 1.9771523914851648e+226

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 1.9771523914851648 \cdot 10^{226}\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 2020083 +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)))