Average Error: 16.5 → 8.3
Time: 27.6s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -8.50296024199504105438153854668089323009 \cdot 10^{149} \lor \neg \left(t \le 1.545233473142941579919826667892007961214 \cdot 10^{127}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t - z\right) \cdot \frac{y}{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 -8.50296024199504105438153854668089323009 \cdot 10^{149} \lor \neg \left(t \le 1.545233473142941579919826667892007961214 \cdot 10^{127}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r413929 = x;
        double r413930 = y;
        double r413931 = r413929 + r413930;
        double r413932 = z;
        double r413933 = t;
        double r413934 = r413932 - r413933;
        double r413935 = r413934 * r413930;
        double r413936 = a;
        double r413937 = r413936 - r413933;
        double r413938 = r413935 / r413937;
        double r413939 = r413931 - r413938;
        return r413939;
}

double f(double x, double y, double z, double t, double a) {
        double r413940 = t;
        double r413941 = -8.502960241995041e+149;
        bool r413942 = r413940 <= r413941;
        double r413943 = 1.5452334731429416e+127;
        bool r413944 = r413940 <= r413943;
        double r413945 = !r413944;
        bool r413946 = r413942 || r413945;
        double r413947 = z;
        double r413948 = r413947 / r413940;
        double r413949 = y;
        double r413950 = x;
        double r413951 = fma(r413948, r413949, r413950);
        double r413952 = r413940 - r413947;
        double r413953 = a;
        double r413954 = r413953 - r413940;
        double r413955 = r413949 / r413954;
        double r413956 = r413952 * r413955;
        double r413957 = r413950 + r413949;
        double r413958 = r413956 + r413957;
        double r413959 = r413946 ? r413951 : r413958;
        return r413959;
}

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.3
Herbie8.3
\[\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 < -8.502960241995041e+149 or 1.5452334731429416e+127 < t

    1. Initial program 31.2

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

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

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

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

    if -8.502960241995041e+149 < t < 1.5452334731429416e+127

    1. Initial program 10.0

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

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

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

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

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

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

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

Reproduce

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