Average Error: 16.3 → 8.8
Time: 21.3s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.459767150779761918638725670658940902065 \cdot 10^{-90} \lor \neg \left(a \le 1.557199236446579255496095790907503303318 \cdot 10^{-151}\right):\\ \;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -1.459767150779761918638725670658940902065 \cdot 10^{-90} \lor \neg \left(a \le 1.557199236446579255496095790907503303318 \cdot 10^{-151}\right):\\
\;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r464018 = x;
        double r464019 = y;
        double r464020 = r464018 + r464019;
        double r464021 = z;
        double r464022 = t;
        double r464023 = r464021 - r464022;
        double r464024 = r464023 * r464019;
        double r464025 = a;
        double r464026 = r464025 - r464022;
        double r464027 = r464024 / r464026;
        double r464028 = r464020 - r464027;
        return r464028;
}

double f(double x, double y, double z, double t, double a) {
        double r464029 = a;
        double r464030 = -1.459767150779762e-90;
        bool r464031 = r464029 <= r464030;
        double r464032 = 1.5571992364465793e-151;
        bool r464033 = r464029 <= r464032;
        double r464034 = !r464033;
        bool r464035 = r464031 || r464034;
        double r464036 = t;
        double r464037 = z;
        double r464038 = r464036 - r464037;
        double r464039 = 1.0;
        double r464040 = r464029 - r464036;
        double r464041 = r464039 / r464040;
        double r464042 = r464038 * r464041;
        double r464043 = y;
        double r464044 = x;
        double r464045 = r464044 + r464043;
        double r464046 = fma(r464042, r464043, r464045);
        double r464047 = r464037 / r464036;
        double r464048 = fma(r464047, r464043, r464044);
        double r464049 = r464035 ? r464046 : r464048;
        return r464049;
}

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.3
Herbie8.8
\[\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 a < -1.459767150779762e-90 or 1.5571992364465793e-151 < a

    1. Initial program 14.9

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

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

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

    if -1.459767150779762e-90 < a < 1.5571992364465793e-151

    1. Initial program 19.8

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

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

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

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

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

Reproduce

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