Average Error: 5.9 → 0.8
Time: 2.6s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -1.1473918177297942 \cdot 10^{219}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 4.65706236165514431 \cdot 10^{145}:\\ \;\;\;\;x + \frac{1}{\frac{a}{y \cdot \left(z - t\right)}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \le -1.1473918177297942 \cdot 10^{219}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)\\

\mathbf{elif}\;y \cdot \left(z - t\right) \le 4.65706236165514431 \cdot 10^{145}:\\
\;\;\;\;x + \frac{1}{\frac{a}{y \cdot \left(z - t\right)}}\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r341369 = x;
        double r341370 = y;
        double r341371 = z;
        double r341372 = t;
        double r341373 = r341371 - r341372;
        double r341374 = r341370 * r341373;
        double r341375 = a;
        double r341376 = r341374 / r341375;
        double r341377 = r341369 + r341376;
        return r341377;
}

double f(double x, double y, double z, double t, double a) {
        double r341378 = y;
        double r341379 = z;
        double r341380 = t;
        double r341381 = r341379 - r341380;
        double r341382 = r341378 * r341381;
        double r341383 = -1.1473918177297942e+219;
        bool r341384 = r341382 <= r341383;
        double r341385 = a;
        double r341386 = r341378 / r341385;
        double r341387 = x;
        double r341388 = fma(r341386, r341381, r341387);
        double r341389 = 4.6570623616551443e+145;
        bool r341390 = r341382 <= r341389;
        double r341391 = 1.0;
        double r341392 = r341385 / r341382;
        double r341393 = r341391 / r341392;
        double r341394 = r341387 + r341393;
        double r341395 = r341381 / r341385;
        double r341396 = r341378 * r341395;
        double r341397 = r341387 + r341396;
        double r341398 = r341390 ? r341394 : r341397;
        double r341399 = r341384 ? r341388 : r341398;
        return r341399;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original5.9
Target0.7
Herbie0.8
\[\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 3 regimes
  2. if (* y (- z t)) < -1.1473918177297942e+219

    1. Initial program 30.3

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

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

    if -1.1473918177297942e+219 < (* y (- z t)) < 4.6570623616551443e+145

    1. Initial program 0.5

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied clear-num0.5

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

    if 4.6570623616551443e+145 < (* y (- z t))

    1. Initial program 19.7

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity19.7

      \[\leadsto x + \frac{y \cdot \left(z - t\right)}{\color{blue}{1 \cdot a}}\]
    4. Applied times-frac2.6

      \[\leadsto x + \color{blue}{\frac{y}{1} \cdot \frac{z - t}{a}}\]
    5. Simplified2.6

      \[\leadsto x + \color{blue}{y} \cdot \frac{z - t}{a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -1.1473918177297942 \cdot 10^{219}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 4.65706236165514431 \cdot 10^{145}:\\ \;\;\;\;x + \frac{1}{\frac{a}{y \cdot \left(z - t\right)}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020064 +o rules:numerics
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
  :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)))