Average Error: 16.6 → 9.3
Time: 30.8s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -6.928903510917508346716947829360185287324 \cdot 10^{-38} \lor \neg \left(a \le 6.088666730586291033322117417137499186149 \cdot 10^{-12}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a - t}, y, x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -6.928903510917508346716947829360185287324 \cdot 10^{-38} \lor \neg \left(a \le 6.088666730586291033322117417137499186149 \cdot 10^{-12}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a - t}, y, x + y\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r420468 = x;
        double r420469 = y;
        double r420470 = r420468 + r420469;
        double r420471 = z;
        double r420472 = t;
        double r420473 = r420471 - r420472;
        double r420474 = r420473 * r420469;
        double r420475 = a;
        double r420476 = r420475 - r420472;
        double r420477 = r420474 / r420476;
        double r420478 = r420470 - r420477;
        return r420478;
}

double f(double x, double y, double z, double t, double a) {
        double r420479 = a;
        double r420480 = -6.928903510917508e-38;
        bool r420481 = r420479 <= r420480;
        double r420482 = 6.088666730586291e-12;
        bool r420483 = r420479 <= r420482;
        double r420484 = !r420483;
        bool r420485 = r420481 || r420484;
        double r420486 = t;
        double r420487 = z;
        double r420488 = r420486 - r420487;
        double r420489 = r420479 - r420486;
        double r420490 = r420488 / r420489;
        double r420491 = y;
        double r420492 = x;
        double r420493 = r420492 + r420491;
        double r420494 = fma(r420490, r420491, r420493);
        double r420495 = r420487 / r420486;
        double r420496 = fma(r420495, r420491, r420492);
        double r420497 = r420485 ? r420494 : r420496;
        return r420497;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.6
Target8.4
Herbie9.3
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.366497088939072697550672266103566343531 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt 1.475429344457723334351036314450840066235 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if a < -6.928903510917508e-38 or 6.088666730586291e-12 < a

    1. Initial program 14.4

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

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

    if -6.928903510917508e-38 < a < 6.088666730586291e-12

    1. Initial program 19.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{a - t}, y, x + y\right)}\]
    3. Taylor expanded around inf 14.4

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    4. Simplified13.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -6.928903510917508346716947829360185287324 \cdot 10^{-38} \lor \neg \left(a \le 6.088666730586291033322117417137499186149 \cdot 10^{-12}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a - t}, y, x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.47542934445772333e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y))))

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