Average Error: 6.1 → 0.4
Time: 11.2s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 2.358413248954256348213035766917854469977 \cdot 10^{175}\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) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 2.358413248954256348213035766917854469977 \cdot 10^{175}\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 r249611 = x;
        double r249612 = y;
        double r249613 = z;
        double r249614 = t;
        double r249615 = r249613 - r249614;
        double r249616 = r249612 * r249615;
        double r249617 = a;
        double r249618 = r249616 / r249617;
        double r249619 = r249611 - r249618;
        return r249619;
}

double f(double x, double y, double z, double t, double a) {
        double r249620 = y;
        double r249621 = z;
        double r249622 = t;
        double r249623 = r249621 - r249622;
        double r249624 = r249620 * r249623;
        double r249625 = -inf.0;
        bool r249626 = r249624 <= r249625;
        double r249627 = 2.3584132489542563e+175;
        bool r249628 = r249624 <= r249627;
        double r249629 = !r249628;
        bool r249630 = r249626 || r249629;
        double r249631 = a;
        double r249632 = r249620 / r249631;
        double r249633 = r249622 - r249621;
        double r249634 = x;
        double r249635 = fma(r249632, r249633, r249634);
        double r249636 = r249624 / r249631;
        double r249637 = r249634 - r249636;
        double r249638 = r249630 ? r249635 : r249637;
        return r249638;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.1
Target0.6
Herbie0.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)) < -inf.0 or 2.3584132489542563e+175 < (* y (- z t))

    1. Initial program 35.2

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

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

    if -inf.0 < (* y (- z t)) < 2.3584132489542563e+175

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) = -\infty \lor \neg \left(y \cdot \left(z - t\right) \le 2.358413248954256348213035766917854469977 \cdot 10^{175}\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 2019326 +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)))