Average Error: 6.0 → 1.2
Time: 11.1s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -9.886386604580156193596869877768365945398 \cdot 10^{99}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 5.339467908683941207143433382917142083728 \cdot 10^{103}:\\ \;\;\;\;x - \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{-y}{\frac{a}{z - t}}\right)\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \le -9.886386604580156193596869877768365945398 \cdot 10^{99}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r227468 = x;
        double r227469 = y;
        double r227470 = z;
        double r227471 = t;
        double r227472 = r227470 - r227471;
        double r227473 = r227469 * r227472;
        double r227474 = a;
        double r227475 = r227473 / r227474;
        double r227476 = r227468 - r227475;
        return r227476;
}

double f(double x, double y, double z, double t, double a) {
        double r227477 = y;
        double r227478 = z;
        double r227479 = t;
        double r227480 = r227478 - r227479;
        double r227481 = r227477 * r227480;
        double r227482 = -9.886386604580156e+99;
        bool r227483 = r227481 <= r227482;
        double r227484 = a;
        double r227485 = r227477 / r227484;
        double r227486 = r227479 - r227478;
        double r227487 = x;
        double r227488 = fma(r227485, r227486, r227487);
        double r227489 = 5.339467908683941e+103;
        bool r227490 = r227481 <= r227489;
        double r227491 = 1.0;
        double r227492 = r227491 / r227484;
        double r227493 = r227481 * r227492;
        double r227494 = r227487 - r227493;
        double r227495 = -r227477;
        double r227496 = r227484 / r227480;
        double r227497 = r227495 / r227496;
        double r227498 = fma(r227491, r227487, r227497);
        double r227499 = r227490 ? r227494 : r227498;
        double r227500 = r227483 ? r227488 : r227499;
        return r227500;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.0
Target0.7
Herbie1.2
\[\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 3 regimes
  2. if (* y (- z t)) < -9.886386604580156e+99

    1. Initial program 15.6

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

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

    if -9.886386604580156e+99 < (* y (- z t)) < 5.339467908683941e+103

    1. Initial program 0.5

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

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

    if 5.339467908683941e+103 < (* y (- z t))

    1. Initial program 16.2

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

      \[\leadsto \color{blue}{1 \cdot x} - \frac{y \cdot \left(z - t\right)}{a}\]
    4. Applied fma-neg16.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, -\frac{y \cdot \left(z - t\right)}{a}\right)}\]
    5. Simplified2.9

      \[\leadsto \mathsf{fma}\left(1, x, \color{blue}{\frac{-y}{\frac{a}{z - t}}}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -9.886386604580156193596869877768365945398 \cdot 10^{99}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 5.339467908683941207143433382917142083728 \cdot 10^{103}:\\ \;\;\;\;x - \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{-y}{\frac{a}{z - t}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019304 +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.07612662163899753e-10) (- x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2.8944268627920891e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

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