Average Error: 6.0 → 1.6
Time: 12.6s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -2.599265967201577977490451997663087588063 \cdot 10^{-112}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;a \le 5.302570006482639697494559695939149034087 \cdot 10^{-78}:\\ \;\;\;\;x - \frac{1}{\frac{a}{\left(z - t\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;a \le -2.599265967201577977490451997663087588063 \cdot 10^{-112}:\\
\;\;\;\;x - y \cdot \frac{z - t}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r242074 = x;
        double r242075 = y;
        double r242076 = z;
        double r242077 = t;
        double r242078 = r242076 - r242077;
        double r242079 = r242075 * r242078;
        double r242080 = a;
        double r242081 = r242079 / r242080;
        double r242082 = r242074 - r242081;
        return r242082;
}

double f(double x, double y, double z, double t, double a) {
        double r242083 = a;
        double r242084 = -2.599265967201578e-112;
        bool r242085 = r242083 <= r242084;
        double r242086 = x;
        double r242087 = y;
        double r242088 = z;
        double r242089 = t;
        double r242090 = r242088 - r242089;
        double r242091 = r242090 / r242083;
        double r242092 = r242087 * r242091;
        double r242093 = r242086 - r242092;
        double r242094 = 5.30257000648264e-78;
        bool r242095 = r242083 <= r242094;
        double r242096 = 1.0;
        double r242097 = r242090 * r242087;
        double r242098 = r242083 / r242097;
        double r242099 = r242096 / r242098;
        double r242100 = r242086 - r242099;
        double r242101 = r242087 / r242083;
        double r242102 = r242089 - r242088;
        double r242103 = fma(r242101, r242102, r242086);
        double r242104 = r242095 ? r242100 : r242103;
        double r242105 = r242085 ? r242093 : r242104;
        return r242105;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.0
Target0.7
Herbie1.6
\[\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 3 regimes
  2. if a < -2.599265967201578e-112

    1. Initial program 7.6

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

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

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

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

    if -2.599265967201578e-112 < a < 5.30257000648264e-78

    1. Initial program 1.1

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

      \[\leadsto x - \color{blue}{\frac{1}{\frac{a}{y \cdot \left(z - t\right)}}}\]
    4. Simplified1.2

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

    if 5.30257000648264e-78 < a

    1. Initial program 7.6

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

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

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

Reproduce

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