Average Error: 6.4 → 0.8
Time: 2.8s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -5.39575041880648583 \cdot 10^{136}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 1.0672653342869649 \cdot 10^{207}:\\ \;\;\;\;x - \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a}\\ \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}\;y \cdot \left(z - t\right) \le -5.39575041880648583 \cdot 10^{136}:\\
\;\;\;\;x - y \cdot \frac{z - t}{a}\\

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

\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 r347853 = x;
        double r347854 = y;
        double r347855 = z;
        double r347856 = t;
        double r347857 = r347855 - r347856;
        double r347858 = r347854 * r347857;
        double r347859 = a;
        double r347860 = r347858 / r347859;
        double r347861 = r347853 - r347860;
        return r347861;
}

double f(double x, double y, double z, double t, double a) {
        double r347862 = y;
        double r347863 = z;
        double r347864 = t;
        double r347865 = r347863 - r347864;
        double r347866 = r347862 * r347865;
        double r347867 = -5.395750418806486e+136;
        bool r347868 = r347866 <= r347867;
        double r347869 = x;
        double r347870 = a;
        double r347871 = r347865 / r347870;
        double r347872 = r347862 * r347871;
        double r347873 = r347869 - r347872;
        double r347874 = 1.0672653342869649e+207;
        bool r347875 = r347866 <= r347874;
        double r347876 = 1.0;
        double r347877 = r347876 / r347870;
        double r347878 = r347866 * r347877;
        double r347879 = r347869 - r347878;
        double r347880 = r347862 / r347870;
        double r347881 = r347864 - r347863;
        double r347882 = fma(r347880, r347881, r347869);
        double r347883 = r347875 ? r347879 : r347882;
        double r347884 = r347868 ? r347873 : r347883;
        return r347884;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.4
Target0.7
Herbie0.8
\[\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)) < -5.395750418806486e+136

    1. Initial program 20.6

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

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

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

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

    if -5.395750418806486e+136 < (* y (- z t)) < 1.0672653342869649e+207

    1. Initial program 0.4

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

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

    if 1.0672653342869649e+207 < (* y (- z t))

    1. Initial program 31.0

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

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

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

Reproduce

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