Average Error: 6.4 → 1.4
Time: 10.7s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -0.0 \lor \neg \left(y \cdot \left(z - t\right) \le 2.458285376760889437383918378967328934713 \cdot 10^{301}\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) \le -0.0 \lor \neg \left(y \cdot \left(z - t\right) \le 2.458285376760889437383918378967328934713 \cdot 10^{301}\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 r178272 = x;
        double r178273 = y;
        double r178274 = z;
        double r178275 = t;
        double r178276 = r178274 - r178275;
        double r178277 = r178273 * r178276;
        double r178278 = a;
        double r178279 = r178277 / r178278;
        double r178280 = r178272 - r178279;
        return r178280;
}

double f(double x, double y, double z, double t, double a) {
        double r178281 = y;
        double r178282 = z;
        double r178283 = t;
        double r178284 = r178282 - r178283;
        double r178285 = r178281 * r178284;
        double r178286 = -0.0;
        bool r178287 = r178285 <= r178286;
        double r178288 = 2.4582853767608894e+301;
        bool r178289 = r178285 <= r178288;
        double r178290 = !r178289;
        bool r178291 = r178287 || r178290;
        double r178292 = a;
        double r178293 = r178281 / r178292;
        double r178294 = r178283 - r178282;
        double r178295 = x;
        double r178296 = fma(r178293, r178294, r178295);
        double r178297 = r178285 / r178292;
        double r178298 = r178295 - r178297;
        double r178299 = r178291 ? r178296 : r178298;
        return r178299;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.4
Target0.7
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753216593153715602325729 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.894426862792089097262541964056085749132 \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)) < -0.0 or 2.4582853767608894e+301 < (* y (- z t))

    1. Initial program 11.2

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

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

    if -0.0 < (* y (- z t)) < 2.4582853767608894e+301

    1. Initial program 0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -0.0 \lor \neg \left(y \cdot \left(z - t\right) \le 2.458285376760889437383918378967328934713 \cdot 10^{301}\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 2019323 +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)))