Average Error: 6.4 → 1.4
Time: 10.9s
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 r200718 = x;
        double r200719 = y;
        double r200720 = z;
        double r200721 = t;
        double r200722 = r200720 - r200721;
        double r200723 = r200719 * r200722;
        double r200724 = a;
        double r200725 = r200723 / r200724;
        double r200726 = r200718 - r200725;
        return r200726;
}

double f(double x, double y, double z, double t, double a) {
        double r200727 = y;
        double r200728 = z;
        double r200729 = t;
        double r200730 = r200728 - r200729;
        double r200731 = r200727 * r200730;
        double r200732 = -0.0;
        bool r200733 = r200731 <= r200732;
        double r200734 = 2.4582853767608894e+301;
        bool r200735 = r200731 <= r200734;
        double r200736 = !r200735;
        bool r200737 = r200733 || r200736;
        double r200738 = a;
        double r200739 = r200727 / r200738;
        double r200740 = r200729 - r200728;
        double r200741 = x;
        double r200742 = fma(r200739, r200740, r200741);
        double r200743 = r200731 / r200738;
        double r200744 = r200741 - r200743;
        double r200745 = r200737 ? r200742 : r200744;
        return r200745;
}

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)))