Average Error: 16.5 → 8.0
Time: 22.7s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le -4.869256490744422828247013908290630268308 \cdot 10^{-232}:\\ \;\;\;\;\mathsf{fma}\left(t - z, \frac{y}{a - t}, y + x\right)\\ \mathbf{elif}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le 2.581593314547877943010122734240759935837 \cdot 10^{-285}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le 4.891049202688294908428058229064567412917 \cdot 10^{301}:\\ \;\;\;\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\ \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}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le -4.869256490744422828247013908290630268308 \cdot 10^{-232}:\\
\;\;\;\;\mathsf{fma}\left(t - z, \frac{y}{a - t}, y + x\right)\\

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

\mathbf{elif}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le 4.891049202688294908428058229064567412917 \cdot 10^{301}:\\
\;\;\;\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\

\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 r19327203 = x;
        double r19327204 = y;
        double r19327205 = r19327203 + r19327204;
        double r19327206 = z;
        double r19327207 = t;
        double r19327208 = r19327206 - r19327207;
        double r19327209 = r19327208 * r19327204;
        double r19327210 = a;
        double r19327211 = r19327210 - r19327207;
        double r19327212 = r19327209 / r19327211;
        double r19327213 = r19327205 - r19327212;
        return r19327213;
}

double f(double x, double y, double z, double t, double a) {
        double r19327214 = y;
        double r19327215 = x;
        double r19327216 = r19327214 + r19327215;
        double r19327217 = z;
        double r19327218 = t;
        double r19327219 = r19327217 - r19327218;
        double r19327220 = r19327219 * r19327214;
        double r19327221 = a;
        double r19327222 = r19327221 - r19327218;
        double r19327223 = r19327220 / r19327222;
        double r19327224 = r19327216 - r19327223;
        double r19327225 = -4.869256490744423e-232;
        bool r19327226 = r19327224 <= r19327225;
        double r19327227 = r19327218 - r19327217;
        double r19327228 = r19327214 / r19327222;
        double r19327229 = fma(r19327227, r19327228, r19327216);
        double r19327230 = 2.581593314547878e-285;
        bool r19327231 = r19327224 <= r19327230;
        double r19327232 = r19327217 / r19327218;
        double r19327233 = fma(r19327232, r19327214, r19327215);
        double r19327234 = 4.891049202688295e+301;
        bool r19327235 = r19327224 <= r19327234;
        double r19327236 = r19327235 ? r19327224 : r19327233;
        double r19327237 = r19327231 ? r19327233 : r19327236;
        double r19327238 = r19327226 ? r19327229 : r19327237;
        return r19327238;
}

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.1
Herbie8.0
\[\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 3 regimes
  2. if (- (+ x y) (/ (* (- z t) y) (- a t))) < -4.869256490744423e-232

    1. Initial program 12.5

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

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

      \[\leadsto \mathsf{fma}\left(t - z, \color{blue}{\frac{1}{\frac{a - t}{y}}}, x + y\right)\]
    5. Using strategy rm
    6. Applied *-un-lft-identity7.5

      \[\leadsto \mathsf{fma}\left(t - z, \frac{1}{\frac{a - t}{\color{blue}{1 \cdot y}}}, x + y\right)\]
    7. Applied *-un-lft-identity7.5

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

      \[\leadsto \mathsf{fma}\left(t - z, \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a - t}{y}}}, x + y\right)\]
    9. Applied add-cube-cbrt7.5

      \[\leadsto \mathsf{fma}\left(t - z, \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a - t}{y}}, x + y\right)\]
    10. Applied times-frac7.5

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

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

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

    if -4.869256490744423e-232 < (- (+ x y) (/ (* (- z t) y) (- a t))) < 2.581593314547878e-285 or 4.891049202688295e+301 < (- (+ x y) (/ (* (- z t) y) (- a t)))

    1. Initial program 58.8

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

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

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

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

    if 2.581593314547878e-285 < (- (+ x y) (/ (* (- z t) y) (- a t))) < 4.891049202688295e+301

    1. Initial program 1.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le -4.869256490744422828247013908290630268308 \cdot 10^{-232}:\\ \;\;\;\;\mathsf{fma}\left(t - z, \frac{y}{a - t}, y + x\right)\\ \mathbf{elif}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le 2.581593314547877943010122734240759935837 \cdot 10^{-285}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le 4.891049202688294908428058229064567412917 \cdot 10^{301}:\\ \;\;\;\;\left(y + x\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1.0 (- 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.0 (- a t))) y))))

  (- (+ x y) (/ (* (- z t) y) (- a t))))