Average Error: 16.5 → 8.6
Time: 5.4s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -8.94712349400520929 \cdot 10^{-168} \lor \neg \left(a \le 8.2322134775541335 \cdot 10^{-92}\right):\\ \;\;\;\;y \cdot \left(\left(t - z\right) \cdot \frac{1}{a - t}\right) + \left(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.94712349400520929 \cdot 10^{-168} \lor \neg \left(a \le 8.2322134775541335 \cdot 10^{-92}\right):\\
\;\;\;\;y \cdot \left(\left(t - z\right) \cdot \frac{1}{a - t}\right) + \left(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 r567383 = x;
        double r567384 = y;
        double r567385 = r567383 + r567384;
        double r567386 = z;
        double r567387 = t;
        double r567388 = r567386 - r567387;
        double r567389 = r567388 * r567384;
        double r567390 = a;
        double r567391 = r567390 - r567387;
        double r567392 = r567389 / r567391;
        double r567393 = r567385 - r567392;
        return r567393;
}

double f(double x, double y, double z, double t, double a) {
        double r567394 = a;
        double r567395 = -8.94712349400521e-168;
        bool r567396 = r567394 <= r567395;
        double r567397 = 8.232213477554133e-92;
        bool r567398 = r567394 <= r567397;
        double r567399 = !r567398;
        bool r567400 = r567396 || r567399;
        double r567401 = y;
        double r567402 = t;
        double r567403 = z;
        double r567404 = r567402 - r567403;
        double r567405 = 1.0;
        double r567406 = r567394 - r567402;
        double r567407 = r567405 / r567406;
        double r567408 = r567404 * r567407;
        double r567409 = r567401 * r567408;
        double r567410 = x;
        double r567411 = r567410 + r567401;
        double r567412 = r567409 + r567411;
        double r567413 = r567403 / r567402;
        double r567414 = fma(r567413, r567401, r567410);
        double r567415 = r567400 ? r567412 : r567414;
        return r567415;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.5
Target8.5
Herbie8.6
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.3664970889390727 \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.47542934445772333 \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.94712349400521e-168 or 8.232213477554133e-92 < a

    1. Initial program 14.9

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

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

      \[\leadsto \color{blue}{\frac{y}{a - t} \cdot \left(t - z\right) + \left(x + y\right)}\]
    5. Using strategy rm
    6. Applied div-inv9.2

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{a - t}\right)} \cdot \left(t - z\right) + \left(x + y\right)\]
    7. Applied associate-*l*8.5

      \[\leadsto \color{blue}{y \cdot \left(\frac{1}{a - t} \cdot \left(t - z\right)\right)} + \left(x + y\right)\]
    8. Simplified8.5

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Using strategy rm
    10. Applied div-inv8.5

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

    if -8.94712349400521e-168 < a < 8.232213477554133e-92

    1. Initial program 20.7

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

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

      \[\leadsto \color{blue}{\frac{y}{a - t} \cdot \left(t - z\right) + \left(x + y\right)}\]
    5. Using strategy rm
    6. Applied div-inv19.9

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{a - t}\right)} \cdot \left(t - z\right) + \left(x + y\right)\]
    7. Applied associate-*l*19.5

      \[\leadsto \color{blue}{y \cdot \left(\frac{1}{a - t} \cdot \left(t - z\right)\right)} + \left(x + y\right)\]
    8. Simplified19.5

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Taylor expanded around inf 10.1

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    10. Simplified8.9

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

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

Reproduce

herbie shell --seed 2020047 +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-07) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y))))

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