Average Error: 16.3 → 8.9
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 -1.92814178504205926 \cdot 10^{65} \lor \neg \left(t \le 4.5256314156925584 \cdot 10^{46}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{t - z}{a - t}, 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 -1.92814178504205926 \cdot 10^{65} \lor \neg \left(t \le 4.5256314156925584 \cdot 10^{46}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r545882 = x;
        double r545883 = y;
        double r545884 = r545882 + r545883;
        double r545885 = z;
        double r545886 = t;
        double r545887 = r545885 - r545886;
        double r545888 = r545887 * r545883;
        double r545889 = a;
        double r545890 = r545889 - r545886;
        double r545891 = r545888 / r545890;
        double r545892 = r545884 - r545891;
        return r545892;
}

double f(double x, double y, double z, double t, double a) {
        double r545893 = t;
        double r545894 = -1.9281417850420593e+65;
        bool r545895 = r545893 <= r545894;
        double r545896 = 4.5256314156925584e+46;
        bool r545897 = r545893 <= r545896;
        double r545898 = !r545897;
        bool r545899 = r545895 || r545898;
        double r545900 = z;
        double r545901 = r545900 / r545893;
        double r545902 = y;
        double r545903 = x;
        double r545904 = fma(r545901, r545902, r545903);
        double r545905 = r545893 - r545900;
        double r545906 = a;
        double r545907 = r545906 - r545893;
        double r545908 = r545905 / r545907;
        double r545909 = r545903 + r545902;
        double r545910 = fma(r545902, r545908, r545909);
        double r545911 = r545899 ? r545904 : r545910;
        return r545911;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.3
Target8.1
Herbie8.9
\[\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 < -1.9281417850420593e+65 or 4.5256314156925584e+46 < t

    1. Initial program 28.2

      \[\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-udef20.0

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

      \[\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.0

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

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

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

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

    if -1.9281417850420593e+65 < t < 4.5256314156925584e+46

    1. Initial program 6.8

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

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

      \[\leadsto \color{blue}{\frac{y}{a - t} \cdot \left(t - z\right) + \left(x + y\right)}\]
    5. Using strategy rm
    6. Applied div-inv5.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*5.6

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

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

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

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

Reproduce

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