Average Error: 6.4 → 1.4
Time: 10.6s
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 r217767 = x;
        double r217768 = y;
        double r217769 = z;
        double r217770 = t;
        double r217771 = r217769 - r217770;
        double r217772 = r217768 * r217771;
        double r217773 = a;
        double r217774 = r217772 / r217773;
        double r217775 = r217767 - r217774;
        return r217775;
}

double f(double x, double y, double z, double t, double a) {
        double r217776 = y;
        double r217777 = z;
        double r217778 = t;
        double r217779 = r217777 - r217778;
        double r217780 = r217776 * r217779;
        double r217781 = -0.0;
        bool r217782 = r217780 <= r217781;
        double r217783 = 2.4582853767608894e+301;
        bool r217784 = r217780 <= r217783;
        double r217785 = !r217784;
        bool r217786 = r217782 || r217785;
        double r217787 = a;
        double r217788 = r217776 / r217787;
        double r217789 = r217778 - r217777;
        double r217790 = x;
        double r217791 = fma(r217788, r217789, r217790);
        double r217792 = r217780 / r217787;
        double r217793 = r217790 - r217792;
        double r217794 = r217786 ? r217791 : r217793;
        return r217794;
}

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