Average Error: 6.1 → 0.5
Time: 9.8s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -8.00872266911859742407687626933145763664 \cdot 10^{184} \lor \neg \left(y \cdot \left(z - t\right) \le 1.495394205446144976596239639301361498263 \cdot 10^{252}\right):\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{-y}{\frac{a}{z - t}}\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 -8.00872266911859742407687626933145763664 \cdot 10^{184} \lor \neg \left(y \cdot \left(z - t\right) \le 1.495394205446144976596239639301361498263 \cdot 10^{252}\right):\\
\;\;\;\;\mathsf{fma}\left(1, x, \frac{-y}{\frac{a}{z - t}}\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 r220832 = x;
        double r220833 = y;
        double r220834 = z;
        double r220835 = t;
        double r220836 = r220834 - r220835;
        double r220837 = r220833 * r220836;
        double r220838 = a;
        double r220839 = r220837 / r220838;
        double r220840 = r220832 - r220839;
        return r220840;
}

double f(double x, double y, double z, double t, double a) {
        double r220841 = y;
        double r220842 = z;
        double r220843 = t;
        double r220844 = r220842 - r220843;
        double r220845 = r220841 * r220844;
        double r220846 = -8.008722669118597e+184;
        bool r220847 = r220845 <= r220846;
        double r220848 = 1.495394205446145e+252;
        bool r220849 = r220845 <= r220848;
        double r220850 = !r220849;
        bool r220851 = r220847 || r220850;
        double r220852 = 1.0;
        double r220853 = x;
        double r220854 = -r220841;
        double r220855 = a;
        double r220856 = r220855 / r220844;
        double r220857 = r220854 / r220856;
        double r220858 = fma(r220852, r220853, r220857);
        double r220859 = r220845 / r220855;
        double r220860 = r220853 - r220859;
        double r220861 = r220851 ? r220858 : r220860;
        return r220861;
}

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.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)) < -8.008722669118597e+184 or 1.495394205446145e+252 < (* y (- z t))

    1. Initial program 31.3

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity31.3

      \[\leadsto \color{blue}{1 \cdot x} - \frac{y \cdot \left(z - t\right)}{a}\]
    4. Applied fma-neg31.3

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

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

    if -8.008722669118597e+184 < (* y (- z t)) < 1.495394205446145e+252

    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}\;y \cdot \left(z - t\right) \le -8.00872266911859742407687626933145763664 \cdot 10^{184} \lor \neg \left(y \cdot \left(z - t\right) \le 1.495394205446144976596239639301361498263 \cdot 10^{252}\right):\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{-y}{\frac{a}{z - t}}\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \end{array}\]

Reproduce

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