Average Error: 16.5 → 8.3
Time: 24.8s
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 r422806 = x;
        double r422807 = y;
        double r422808 = r422806 + r422807;
        double r422809 = z;
        double r422810 = t;
        double r422811 = r422809 - r422810;
        double r422812 = r422811 * r422807;
        double r422813 = a;
        double r422814 = r422813 - r422810;
        double r422815 = r422812 / r422814;
        double r422816 = r422808 - r422815;
        return r422816;
}

double f(double x, double y, double z, double t, double a) {
        double r422817 = t;
        double r422818 = -8.502960241995041e+149;
        bool r422819 = r422817 <= r422818;
        double r422820 = 1.5452334731429416e+127;
        bool r422821 = r422817 <= r422820;
        double r422822 = !r422821;
        bool r422823 = r422819 || r422822;
        double r422824 = z;
        double r422825 = r422824 / r422817;
        double r422826 = y;
        double r422827 = x;
        double r422828 = fma(r422825, r422826, r422827);
        double r422829 = r422817 - r422824;
        double r422830 = a;
        double r422831 = r422830 - r422817;
        double r422832 = r422826 / r422831;
        double r422833 = r422829 * r422832;
        double r422834 = r422827 + r422826;
        double r422835 = r422833 + r422834;
        double r422836 = r422823 ? r422828 : r422835;
        return r422836;
}

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