Average Error: 6.3 → 1.4
Time: 7.7s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -4.9168923767645714 \cdot 10^{80}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 2.08730857278766648 \cdot 10^{115}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \le -4.9168923767645714 \cdot 10^{80}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r247166 = x;
        double r247167 = y;
        double r247168 = z;
        double r247169 = t;
        double r247170 = r247168 - r247169;
        double r247171 = r247167 * r247170;
        double r247172 = a;
        double r247173 = r247171 / r247172;
        double r247174 = r247166 + r247173;
        return r247174;
}

double f(double x, double y, double z, double t, double a) {
        double r247175 = y;
        double r247176 = z;
        double r247177 = t;
        double r247178 = r247176 - r247177;
        double r247179 = r247175 * r247178;
        double r247180 = -4.916892376764571e+80;
        bool r247181 = r247179 <= r247180;
        double r247182 = x;
        double r247183 = a;
        double r247184 = r247178 / r247183;
        double r247185 = r247175 * r247184;
        double r247186 = r247182 + r247185;
        double r247187 = 2.0873085727876665e+115;
        bool r247188 = r247179 <= r247187;
        double r247189 = r247179 / r247183;
        double r247190 = r247182 + r247189;
        double r247191 = r247175 / r247183;
        double r247192 = fma(r247191, r247178, r247182);
        double r247193 = r247188 ? r247190 : r247192;
        double r247194 = r247181 ? r247186 : r247193;
        return r247194;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.3
Target0.7
Herbie1.4
\[\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 (* y (- z t)) < -4.916892376764571e+80

    1. Initial program 14.6

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

      \[\leadsto x + \frac{y \cdot \left(z - t\right)}{\color{blue}{1 \cdot a}}\]
    4. Applied times-frac3.8

      \[\leadsto x + \color{blue}{\frac{y}{1} \cdot \frac{z - t}{a}}\]
    5. Simplified3.8

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

    if -4.916892376764571e+80 < (* y (- z t)) < 2.0873085727876665e+115

    1. Initial program 0.5

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

    if 2.0873085727876665e+115 < (* y (- z t))

    1. Initial program 18.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.4

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

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
  :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)))