Average Error: 6.1 → 0.5
Time: 17.1s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;\left(z - t\right) \cdot y = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \mathbf{elif}\;\left(z - t\right) \cdot y \le 4.602775554656434635046377876682959240373 \cdot 10^{138}:\\ \;\;\;\;x - \frac{\left(z - t\right) \cdot y}{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}\;\left(z - t\right) \cdot y = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\

\mathbf{elif}\;\left(z - t\right) \cdot y \le 4.602775554656434635046377876682959240373 \cdot 10^{138}:\\
\;\;\;\;x - \frac{\left(z - t\right) \cdot y}{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 r13649355 = x;
        double r13649356 = y;
        double r13649357 = z;
        double r13649358 = t;
        double r13649359 = r13649357 - r13649358;
        double r13649360 = r13649356 * r13649359;
        double r13649361 = a;
        double r13649362 = r13649360 / r13649361;
        double r13649363 = r13649355 - r13649362;
        return r13649363;
}

double f(double x, double y, double z, double t, double a) {
        double r13649364 = z;
        double r13649365 = t;
        double r13649366 = r13649364 - r13649365;
        double r13649367 = y;
        double r13649368 = r13649366 * r13649367;
        double r13649369 = -inf.0;
        bool r13649370 = r13649368 <= r13649369;
        double r13649371 = a;
        double r13649372 = r13649367 / r13649371;
        double r13649373 = r13649365 - r13649364;
        double r13649374 = x;
        double r13649375 = fma(r13649372, r13649373, r13649374);
        double r13649376 = 4.6027755546564346e+138;
        bool r13649377 = r13649368 <= r13649376;
        double r13649378 = r13649368 / r13649371;
        double r13649379 = r13649374 - r13649378;
        double r13649380 = r13649377 ? r13649379 : r13649375;
        double r13649381 = r13649370 ? r13649375 : r13649380;
        return r13649381;
}

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.7
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)) < -inf.0 or 4.6027755546564346e+138 < (* y (- z t))

    1. Initial program 30.6

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

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

    if -inf.0 < (* y (- z t)) < 4.6027755546564346e+138

    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}\;\left(z - t\right) \cdot y = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \mathbf{elif}\;\left(z - t\right) \cdot y \le 4.602775554656434635046377876682959240373 \cdot 10^{138}:\\ \;\;\;\;x - \frac{\left(z - t\right) \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

  (- x (/ (* y (- z t)) a)))