Average Error: 16.5 → 8.3
Time: 28.5s
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 r355812 = x;
        double r355813 = y;
        double r355814 = r355812 + r355813;
        double r355815 = z;
        double r355816 = t;
        double r355817 = r355815 - r355816;
        double r355818 = r355817 * r355813;
        double r355819 = a;
        double r355820 = r355819 - r355816;
        double r355821 = r355818 / r355820;
        double r355822 = r355814 - r355821;
        return r355822;
}

double f(double x, double y, double z, double t, double a) {
        double r355823 = t;
        double r355824 = -8.502960241995041e+149;
        bool r355825 = r355823 <= r355824;
        double r355826 = 1.5452334731429416e+127;
        bool r355827 = r355823 <= r355826;
        double r355828 = !r355827;
        bool r355829 = r355825 || r355828;
        double r355830 = z;
        double r355831 = r355830 / r355823;
        double r355832 = y;
        double r355833 = x;
        double r355834 = fma(r355831, r355832, r355833);
        double r355835 = r355823 - r355830;
        double r355836 = a;
        double r355837 = r355836 - r355823;
        double r355838 = r355832 / r355837;
        double r355839 = r355835 * r355838;
        double r355840 = r355833 + r355832;
        double r355841 = r355839 + r355840;
        double r355842 = r355829 ? r355834 : r355841;
        return r355842;
}

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))))