Average Error: 5.9 → 1.2
Time: 9.3s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.39950285805274381 \cdot 10^{104}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{elif}\;a \le 3.75740059193433464 \cdot 10^{65}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \left(-\frac{z - t}{a}\right) \cdot y\right)\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;a \le -1.39950285805274381 \cdot 10^{104}:\\
\;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r312092 = x;
        double r312093 = y;
        double r312094 = z;
        double r312095 = t;
        double r312096 = r312094 - r312095;
        double r312097 = r312093 * r312096;
        double r312098 = a;
        double r312099 = r312097 / r312098;
        double r312100 = r312092 - r312099;
        return r312100;
}

double f(double x, double y, double z, double t, double a) {
        double r312101 = a;
        double r312102 = -1.3995028580527438e+104;
        bool r312103 = r312101 <= r312102;
        double r312104 = x;
        double r312105 = y;
        double r312106 = z;
        double r312107 = t;
        double r312108 = r312106 - r312107;
        double r312109 = r312101 / r312108;
        double r312110 = r312105 / r312109;
        double r312111 = r312104 - r312110;
        double r312112 = 3.7574005919343346e+65;
        bool r312113 = r312101 <= r312112;
        double r312114 = r312105 * r312108;
        double r312115 = r312114 / r312101;
        double r312116 = r312104 - r312115;
        double r312117 = 1.0;
        double r312118 = r312108 / r312101;
        double r312119 = -r312118;
        double r312120 = r312119 * r312105;
        double r312121 = fma(r312117, r312104, r312120);
        double r312122 = r312113 ? r312116 : r312121;
        double r312123 = r312103 ? r312111 : r312122;
        return r312123;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original5.9
Target0.7
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \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 3 regimes
  2. if a < -1.3995028580527438e+104

    1. Initial program 12.4

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied associate-/l*0.7

      \[\leadsto x - \color{blue}{\frac{y}{\frac{a}{z - t}}}\]

    if -1.3995028580527438e+104 < a < 3.7574005919343346e+65

    1. Initial program 1.6

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

    if 3.7574005919343346e+65 < a

    1. Initial program 10.0

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

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

      \[\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}{\left(-\frac{z - t}{a}\right) \cdot y}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.39950285805274381 \cdot 10^{104}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{elif}\;a \le 3.75740059193433464 \cdot 10^{65}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \left(-\frac{z - t}{a}\right) \cdot y\right)\\ \end{array}\]

Reproduce

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