Average Error: 10.5 → 1.5
Time: 20.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.41607876912572170501264147417537244743 \cdot 10^{-236} \lor \neg \left(z \le 1.1044784079803560131683569738891510282 \cdot 10^{-268}\right):\\ \;\;\;\;\frac{t}{\frac{a - z}{y - z}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -1.41607876912572170501264147417537244743 \cdot 10^{-236} \lor \neg \left(z \le 1.1044784079803560131683569738891510282 \cdot 10^{-268}\right):\\
\;\;\;\;\frac{t}{\frac{a - z}{y - z}} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r363237 = x;
        double r363238 = y;
        double r363239 = z;
        double r363240 = r363238 - r363239;
        double r363241 = t;
        double r363242 = r363240 * r363241;
        double r363243 = a;
        double r363244 = r363243 - r363239;
        double r363245 = r363242 / r363244;
        double r363246 = r363237 + r363245;
        return r363246;
}

double f(double x, double y, double z, double t, double a) {
        double r363247 = z;
        double r363248 = -1.4160787691257217e-236;
        bool r363249 = r363247 <= r363248;
        double r363250 = 1.104478407980356e-268;
        bool r363251 = r363247 <= r363250;
        double r363252 = !r363251;
        bool r363253 = r363249 || r363252;
        double r363254 = t;
        double r363255 = a;
        double r363256 = r363255 - r363247;
        double r363257 = y;
        double r363258 = r363257 - r363247;
        double r363259 = r363256 / r363258;
        double r363260 = r363254 / r363259;
        double r363261 = x;
        double r363262 = r363260 + r363261;
        double r363263 = r363254 / r363255;
        double r363264 = fma(r363263, r363257, r363261);
        double r363265 = r363253 ? r363262 : r363264;
        return r363265;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.5
Target0.7
Herbie1.5
\[\begin{array}{l} \mathbf{if}\;t \lt -1.068297449017406694366747246993994850729 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.911094988758637497591020599238553861375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.4160787691257217e-236 or 1.104478407980356e-268 < z

    1. Initial program 11.0

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{\frac{a - z}{y - z}}}, t, x\right)\]
    5. Using strategy rm
    6. Applied add-cube-cbrt1.5

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{\frac{1}{\sqrt[3]{\frac{a - z}{y - z}}}}{\sqrt[3]{\frac{a - z}{y - z}}} \cdot \color{blue}{\frac{1}{\sqrt[3]{\frac{a - z}{y - z}}}}, t, x\right)\]
    11. Using strategy rm
    12. Applied fma-udef1.5

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

      \[\leadsto \color{blue}{\frac{t}{\frac{a - z}{y - z}}} + x\]

    if -1.4160787691257217e-236 < z < 1.104478407980356e-268

    1. Initial program 5.0

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

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

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

      \[\leadsto \color{blue}{x + \frac{t \cdot y}{a}}\]
    6. Simplified6.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.41607876912572170501264147417537244743 \cdot 10^{-236} \lor \neg \left(z \le 1.1044784079803560131683569738891510282 \cdot 10^{-268}\right):\\ \;\;\;\;\frac{t}{\frac{a - z}{y - z}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\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, A"
  :precision binary64

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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