Average Error: 5.6 → 1.3
Time: 17.2s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(z - t\right) \cdot y}{a} \le -3.6034487369576053 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\ \mathbf{elif}\;\frac{\left(z - t\right) \cdot y}{a} \le 7.104613061093266 \cdot 10^{+290}:\\ \;\;\;\;x + \frac{\left(z - t\right) \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;\frac{\left(z - t\right) \cdot y}{a} \le -3.6034487369576053 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r16165532 = x;
        double r16165533 = y;
        double r16165534 = z;
        double r16165535 = t;
        double r16165536 = r16165534 - r16165535;
        double r16165537 = r16165533 * r16165536;
        double r16165538 = a;
        double r16165539 = r16165537 / r16165538;
        double r16165540 = r16165532 + r16165539;
        return r16165540;
}

double f(double x, double y, double z, double t, double a) {
        double r16165541 = z;
        double r16165542 = t;
        double r16165543 = r16165541 - r16165542;
        double r16165544 = y;
        double r16165545 = r16165543 * r16165544;
        double r16165546 = a;
        double r16165547 = r16165545 / r16165546;
        double r16165548 = -3.6034487369576053e-13;
        bool r16165549 = r16165547 <= r16165548;
        double r16165550 = r16165544 / r16165546;
        double r16165551 = x;
        double r16165552 = fma(r16165543, r16165550, r16165551);
        double r16165553 = 7.104613061093266e+290;
        bool r16165554 = r16165547 <= r16165553;
        double r16165555 = r16165551 + r16165547;
        double r16165556 = r16165554 ? r16165555 : r16165552;
        double r16165557 = r16165549 ? r16165552 : r16165556;
        return r16165557;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original5.6
Target0.7
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;y \lt -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.894426862792089 \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)) a) < -3.6034487369576053e-13 or 7.104613061093266e+290 < (/ (* y (- z t)) a)

    1. Initial program 16.7

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

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

    if -3.6034487369576053e-13 < (/ (* y (- z t)) a) < 7.104613061093266e+290

    1. Initial program 0.5

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.3

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

Reproduce

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

  :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)))