Average Error: 16.6 → 10.0
Time: 4.3s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.0093387841425542 \cdot 10^{-85}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - t}{y}}, t - z, x + y\right)\\ \mathbf{elif}\;a \le 5.6339865852383654 \cdot 10^{29}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t - z}{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}\;a \le -1.0093387841425542 \cdot 10^{-85}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - t}{y}}, t - z, x + y\right)\\

\mathbf{elif}\;a \le 5.6339865852383654 \cdot 10^{29}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r575232 = x;
        double r575233 = y;
        double r575234 = r575232 + r575233;
        double r575235 = z;
        double r575236 = t;
        double r575237 = r575235 - r575236;
        double r575238 = r575237 * r575233;
        double r575239 = a;
        double r575240 = r575239 - r575236;
        double r575241 = r575238 / r575240;
        double r575242 = r575234 - r575241;
        return r575242;
}

double f(double x, double y, double z, double t, double a) {
        double r575243 = a;
        double r575244 = -1.0093387841425542e-85;
        bool r575245 = r575243 <= r575244;
        double r575246 = 1.0;
        double r575247 = t;
        double r575248 = r575243 - r575247;
        double r575249 = y;
        double r575250 = r575248 / r575249;
        double r575251 = r575246 / r575250;
        double r575252 = z;
        double r575253 = r575247 - r575252;
        double r575254 = x;
        double r575255 = r575254 + r575249;
        double r575256 = fma(r575251, r575253, r575255);
        double r575257 = 5.6339865852383654e+29;
        bool r575258 = r575243 <= r575257;
        double r575259 = r575252 / r575247;
        double r575260 = fma(r575259, r575249, r575254);
        double r575261 = r575253 / r575248;
        double r575262 = r575249 * r575261;
        double r575263 = r575262 + r575255;
        double r575264 = r575258 ? r575260 : r575263;
        double r575265 = r575245 ? r575256 : r575264;
        return r575265;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.6
Target8.2
Herbie10.0
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.3664970889390727 \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.47542934445772333 \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 3 regimes
  2. if a < -1.0093387841425542e-85

    1. Initial program 15.1

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

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

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

    if -1.0093387841425542e-85 < a < 5.6339865852383654e+29

    1. Initial program 19.2

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

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

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

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

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

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Taylor expanded around inf 14.8

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    10. Simplified13.7

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

    if 5.6339865852383654e+29 < a

    1. Initial program 14.2

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.0093387841425542 \cdot 10^{-85}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - t}{y}}, t - z, x + y\right)\\ \mathbf{elif}\;a \le 5.6339865852383654 \cdot 10^{29}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \end{array}\]

Reproduce

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