Average Error: 16.6 → 9.3
Time: 28.1s
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 r345378 = x;
        double r345379 = y;
        double r345380 = r345378 + r345379;
        double r345381 = z;
        double r345382 = t;
        double r345383 = r345381 - r345382;
        double r345384 = r345383 * r345379;
        double r345385 = a;
        double r345386 = r345385 - r345382;
        double r345387 = r345384 / r345386;
        double r345388 = r345380 - r345387;
        return r345388;
}

double f(double x, double y, double z, double t, double a) {
        double r345389 = a;
        double r345390 = -6.928903510917508e-38;
        bool r345391 = r345389 <= r345390;
        double r345392 = 6.088666730586291e-12;
        bool r345393 = r345389 <= r345392;
        double r345394 = !r345393;
        bool r345395 = r345391 || r345394;
        double r345396 = t;
        double r345397 = z;
        double r345398 = r345396 - r345397;
        double r345399 = r345389 - r345396;
        double r345400 = r345398 / r345399;
        double r345401 = y;
        double r345402 = x;
        double r345403 = r345402 + r345401;
        double r345404 = fma(r345400, r345401, r345403);
        double r345405 = r345397 / r345396;
        double r345406 = fma(r345405, r345401, r345402);
        double r345407 = r345395 ? r345404 : r345406;
        return r345407;
}

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