Average Error: 16.5 → 8.0
Time: 22.8s
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 r22934082 = x;
        double r22934083 = y;
        double r22934084 = r22934082 + r22934083;
        double r22934085 = z;
        double r22934086 = t;
        double r22934087 = r22934085 - r22934086;
        double r22934088 = r22934087 * r22934083;
        double r22934089 = a;
        double r22934090 = r22934089 - r22934086;
        double r22934091 = r22934088 / r22934090;
        double r22934092 = r22934084 - r22934091;
        return r22934092;
}

double f(double x, double y, double z, double t, double a) {
        double r22934093 = y;
        double r22934094 = x;
        double r22934095 = r22934093 + r22934094;
        double r22934096 = z;
        double r22934097 = t;
        double r22934098 = r22934096 - r22934097;
        double r22934099 = r22934098 * r22934093;
        double r22934100 = a;
        double r22934101 = r22934100 - r22934097;
        double r22934102 = r22934099 / r22934101;
        double r22934103 = r22934095 - r22934102;
        double r22934104 = -4.869256490744423e-232;
        bool r22934105 = r22934103 <= r22934104;
        double r22934106 = r22934097 - r22934096;
        double r22934107 = r22934093 / r22934101;
        double r22934108 = fma(r22934106, r22934107, r22934095);
        double r22934109 = 2.581593314547878e-285;
        bool r22934110 = r22934103 <= r22934109;
        double r22934111 = r22934096 / r22934097;
        double r22934112 = fma(r22934111, r22934093, r22934094);
        double r22934113 = 4.891049202688295e+301;
        bool r22934114 = r22934103 <= r22934113;
        double r22934115 = r22934114 ? r22934103 : r22934112;
        double r22934116 = r22934110 ? r22934112 : r22934115;
        double r22934117 = r22934105 ? r22934108 : r22934116;
        return r22934117;
}

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