Average Error: 16.2 → 8.5
Time: 4.2s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -9.7413021954978702 \cdot 10^{158} \lor \neg \left(t \le 9.72570957505015151 \cdot 10^{93}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -9.7413021954978702 \cdot 10^{158} \lor \neg \left(t \le 9.72570957505015151 \cdot 10^{93}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r855479 = x;
        double r855480 = y;
        double r855481 = r855479 + r855480;
        double r855482 = z;
        double r855483 = t;
        double r855484 = r855482 - r855483;
        double r855485 = r855484 * r855480;
        double r855486 = a;
        double r855487 = r855486 - r855483;
        double r855488 = r855485 / r855487;
        double r855489 = r855481 - r855488;
        return r855489;
}

double f(double x, double y, double z, double t, double a) {
        double r855490 = t;
        double r855491 = -9.74130219549787e+158;
        bool r855492 = r855490 <= r855491;
        double r855493 = 9.725709575050152e+93;
        bool r855494 = r855490 <= r855493;
        double r855495 = !r855494;
        bool r855496 = r855492 || r855495;
        double r855497 = z;
        double r855498 = r855497 / r855490;
        double r855499 = y;
        double r855500 = x;
        double r855501 = fma(r855498, r855499, r855500);
        double r855502 = r855490 - r855497;
        double r855503 = a;
        double r855504 = r855503 - r855490;
        double r855505 = r855502 / r855504;
        double r855506 = r855499 * r855505;
        double r855507 = r855500 + r855499;
        double r855508 = r855506 + r855507;
        double r855509 = r855496 ? r855501 : r855508;
        return r855509;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.2
Target8.1
Herbie8.5
\[\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 t < -9.74130219549787e+158 or 9.725709575050152e+93 < t

    1. Initial program 30.3

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

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

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

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

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

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

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

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

    if -9.74130219549787e+158 < t < 9.725709575050152e+93

    1. Initial program 9.7

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

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

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

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

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

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

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

Reproduce

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