Average Error: 16.4 → 8.2
Time: 16.8s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.218846766163297479976782027313945770018 \cdot 10^{82} \lor \neg \left(t \le 7.272461153412323810714338479659024421864 \cdot 10^{119}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{a - t}, y, 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.218846766163297479976782027313945770018 \cdot 10^{82} \lor \neg \left(t \le 7.272461153412323810714338479659024421864 \cdot 10^{119}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r382909 = x;
        double r382910 = y;
        double r382911 = r382909 + r382910;
        double r382912 = z;
        double r382913 = t;
        double r382914 = r382912 - r382913;
        double r382915 = r382914 * r382910;
        double r382916 = a;
        double r382917 = r382916 - r382913;
        double r382918 = r382915 / r382917;
        double r382919 = r382911 - r382918;
        return r382919;
}

double f(double x, double y, double z, double t, double a) {
        double r382920 = t;
        double r382921 = -1.2188467661632975e+82;
        bool r382922 = r382920 <= r382921;
        double r382923 = 7.272461153412324e+119;
        bool r382924 = r382920 <= r382923;
        double r382925 = !r382924;
        bool r382926 = r382922 || r382925;
        double r382927 = z;
        double r382928 = r382927 / r382920;
        double r382929 = y;
        double r382930 = x;
        double r382931 = fma(r382928, r382929, r382930);
        double r382932 = r382920 - r382927;
        double r382933 = a;
        double r382934 = r382933 - r382920;
        double r382935 = r382932 / r382934;
        double r382936 = r382930 + r382929;
        double r382937 = fma(r382935, r382929, r382936);
        double r382938 = r382926 ? r382931 : r382937;
        return r382938;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.4
Target8.3
Herbie8.2
\[\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 t < -1.2188467661632975e+82 or 7.272461153412324e+119 < t

    1. Initial program 30.2

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

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

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

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

    if -1.2188467661632975e+82 < t < 7.272461153412324e+119

    1. Initial program 8.3

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

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

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

Reproduce

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