Average Error: 16.7 → 9.1
Time: 21.7s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -8.75767676681428562102978535228254464326 \cdot 10^{-126} \lor \neg \left(a \le 1.018376891629483722524011547441982833577 \cdot 10^{-117}\right):\\ \;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{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 -8.75767676681428562102978535228254464326 \cdot 10^{-126} \lor \neg \left(a \le 1.018376891629483722524011547441982833577 \cdot 10^{-117}\right):\\
\;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{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 r374599 = x;
        double r374600 = y;
        double r374601 = r374599 + r374600;
        double r374602 = z;
        double r374603 = t;
        double r374604 = r374602 - r374603;
        double r374605 = r374604 * r374600;
        double r374606 = a;
        double r374607 = r374606 - r374603;
        double r374608 = r374605 / r374607;
        double r374609 = r374601 - r374608;
        return r374609;
}

double f(double x, double y, double z, double t, double a) {
        double r374610 = a;
        double r374611 = -8.757676766814286e-126;
        bool r374612 = r374610 <= r374611;
        double r374613 = 1.0183768916294837e-117;
        bool r374614 = r374610 <= r374613;
        double r374615 = !r374614;
        bool r374616 = r374612 || r374615;
        double r374617 = t;
        double r374618 = z;
        double r374619 = r374617 - r374618;
        double r374620 = 1.0;
        double r374621 = r374610 - r374617;
        double r374622 = r374620 / r374621;
        double r374623 = r374619 * r374622;
        double r374624 = y;
        double r374625 = x;
        double r374626 = r374625 + r374624;
        double r374627 = fma(r374623, r374624, r374626);
        double r374628 = r374618 / r374617;
        double r374629 = fma(r374628, r374624, r374625);
        double r374630 = r374616 ? r374627 : r374629;
        return r374630;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.7
Target8.6
Herbie9.1
\[\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 < -8.757676766814286e-126 or 1.0183768916294837e-117 < a

    1. Initial program 15.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{a - t}, y, x + y\right)}\]
    3. Using strategy rm
    4. Applied div-inv8.6

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

    if -8.757676766814286e-126 < a < 1.0183768916294837e-117

    1. Initial program 20.6

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

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

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

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

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

Reproduce

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