Average Error: 6.1 → 0.6
Time: 37.2s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -748199.857216111:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\ \mathbf{elif}\;a \le 2.3164280398826682 \cdot 10^{+52}:\\ \;\;\;\;\frac{y \cdot \left(t - z\right)}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;a \le -748199.857216111:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\

\mathbf{elif}\;a \le 2.3164280398826682 \cdot 10^{+52}:\\
\;\;\;\;\frac{y \cdot \left(t - z\right)}{a} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r13432877 = x;
        double r13432878 = y;
        double r13432879 = z;
        double r13432880 = t;
        double r13432881 = r13432879 - r13432880;
        double r13432882 = r13432878 * r13432881;
        double r13432883 = a;
        double r13432884 = r13432882 / r13432883;
        double r13432885 = r13432877 - r13432884;
        return r13432885;
}

double f(double x, double y, double z, double t, double a) {
        double r13432886 = a;
        double r13432887 = -748199.857216111;
        bool r13432888 = r13432886 <= r13432887;
        double r13432889 = t;
        double r13432890 = z;
        double r13432891 = r13432889 - r13432890;
        double r13432892 = r13432891 / r13432886;
        double r13432893 = y;
        double r13432894 = x;
        double r13432895 = fma(r13432892, r13432893, r13432894);
        double r13432896 = 2.3164280398826682e+52;
        bool r13432897 = r13432886 <= r13432896;
        double r13432898 = r13432893 * r13432891;
        double r13432899 = r13432898 / r13432886;
        double r13432900 = r13432899 + r13432894;
        double r13432901 = r13432897 ? r13432900 : r13432895;
        double r13432902 = r13432888 ? r13432895 : r13432901;
        return r13432902;
}

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.6
\[\begin{array}{l} \mathbf{if}\;y \lt -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.894426862792089 \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 a < -748199.857216111 or 2.3164280398826682e+52 < a

    1. Initial program 10.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef0.5

      \[\leadsto \color{blue}{\frac{t - z}{a} \cdot y + x}\]
    5. Using strategy rm
    6. Applied fma-def0.5

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

    if -748199.857216111 < a < 2.3164280398826682e+52

    1. Initial program 0.8

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef12.5

      \[\leadsto \color{blue}{\frac{t - z}{a} \cdot y + x}\]
    5. Using strategy rm
    6. Applied associate-*l/0.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -748199.857216111:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\ \mathbf{elif}\;a \le 2.3164280398826682 \cdot 10^{+52}:\\ \;\;\;\;\frac{y \cdot \left(t - z\right)}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"

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