Average Error: 6.3 → 0.5
Time: 19.5s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a} = -\infty \lor \neg \left(\frac{y \cdot \left(z - t\right)}{a} \le 1.532969307568607748245310550315122934408 \cdot 10^{298}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, \left(-\frac{t}{\frac{a}{y}}\right) + x\right) - \mathsf{fma}\left(-x, 1, 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}\;\frac{y \cdot \left(z - t\right)}{a} = -\infty \lor \neg \left(\frac{y \cdot \left(z - t\right)}{a} \le 1.532969307568607748245310550315122934408 \cdot 10^{298}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, \left(-\frac{t}{\frac{a}{y}}\right) + x\right) - \mathsf{fma}\left(-x, 1, 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 r192249 = x;
        double r192250 = y;
        double r192251 = z;
        double r192252 = t;
        double r192253 = r192251 - r192252;
        double r192254 = r192250 * r192253;
        double r192255 = a;
        double r192256 = r192254 / r192255;
        double r192257 = r192249 + r192256;
        return r192257;
}

double f(double x, double y, double z, double t, double a) {
        double r192258 = y;
        double r192259 = z;
        double r192260 = t;
        double r192261 = r192259 - r192260;
        double r192262 = r192258 * r192261;
        double r192263 = a;
        double r192264 = r192262 / r192263;
        double r192265 = -inf.0;
        bool r192266 = r192264 <= r192265;
        double r192267 = 1.5329693075686077e+298;
        bool r192268 = r192264 <= r192267;
        double r192269 = !r192268;
        bool r192270 = r192266 || r192269;
        double r192271 = r192259 / r192263;
        double r192272 = r192263 / r192258;
        double r192273 = r192260 / r192272;
        double r192274 = -r192273;
        double r192275 = x;
        double r192276 = r192274 + r192275;
        double r192277 = fma(r192271, r192258, r192276);
        double r192278 = -r192275;
        double r192279 = 1.0;
        double r192280 = fma(r192278, r192279, r192275);
        double r192281 = r192277 - r192280;
        double r192282 = r192275 + r192264;
        double r192283 = r192270 ? r192281 : r192282;
        return r192283;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.3
Target0.7
Herbie0.5
\[\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)) a) < -inf.0 or 1.5329693075686077e+298 < (/ (* y (- z t)) a)

    1. Initial program 61.1

      \[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)}\]
    3. Using strategy rm
    4. Applied fma-udef0.6

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

      \[\leadsto \color{blue}{\frac{z - t}{\frac{a}{y}}} + x\]
    6. Using strategy rm
    7. Applied div-sub0.6

      \[\leadsto \color{blue}{\left(\frac{z}{\frac{a}{y}} - \frac{t}{\frac{a}{y}}\right)} + x\]
    8. Applied associate-+l-0.6

      \[\leadsto \color{blue}{\frac{z}{\frac{a}{y}} - \left(\frac{t}{\frac{a}{y}} - x\right)}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity0.6

      \[\leadsto \frac{z}{\frac{a}{y}} - \left(\frac{t}{\frac{a}{y}} - \color{blue}{1 \cdot x}\right)\]
    11. Applied add-sqr-sqrt32.8

      \[\leadsto \frac{z}{\frac{a}{y}} - \left(\color{blue}{\sqrt{\frac{t}{\frac{a}{y}}} \cdot \sqrt{\frac{t}{\frac{a}{y}}}} - 1 \cdot x\right)\]
    12. Applied prod-diff32.8

      \[\leadsto \frac{z}{\frac{a}{y}} - \color{blue}{\left(\mathsf{fma}\left(\sqrt{\frac{t}{\frac{a}{y}}}, \sqrt{\frac{t}{\frac{a}{y}}}, -x \cdot 1\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)\right)}\]
    13. Applied associate--r+32.8

      \[\leadsto \color{blue}{\left(\frac{z}{\frac{a}{y}} - \mathsf{fma}\left(\sqrt{\frac{t}{\frac{a}{y}}}, \sqrt{\frac{t}{\frac{a}{y}}}, -x \cdot 1\right)\right) - \mathsf{fma}\left(-x, 1, x \cdot 1\right)}\]
    14. Simplified1.4

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

    if -inf.0 < (/ (* y (- z t)) a) < 1.5329693075686077e+298

    1. Initial program 0.4

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

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

Reproduce

herbie shell --seed 2019212 +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.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)))