Average Error: 10.5 → 1.5
Time: 19.7s
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 r377040 = x;
        double r377041 = y;
        double r377042 = z;
        double r377043 = r377041 - r377042;
        double r377044 = t;
        double r377045 = r377043 * r377044;
        double r377046 = a;
        double r377047 = r377046 - r377042;
        double r377048 = r377045 / r377047;
        double r377049 = r377040 + r377048;
        return r377049;
}

double f(double x, double y, double z, double t, double a) {
        double r377050 = z;
        double r377051 = -1.4160787691257217e-236;
        bool r377052 = r377050 <= r377051;
        double r377053 = 1.104478407980356e-268;
        bool r377054 = r377050 <= r377053;
        double r377055 = !r377054;
        bool r377056 = r377052 || r377055;
        double r377057 = t;
        double r377058 = a;
        double r377059 = r377058 - r377050;
        double r377060 = y;
        double r377061 = r377060 - r377050;
        double r377062 = r377059 / r377061;
        double r377063 = r377057 / r377062;
        double r377064 = x;
        double r377065 = r377063 + r377064;
        double r377066 = r377057 / r377058;
        double r377067 = fma(r377066, r377060, r377064);
        double r377068 = r377056 ? r377065 : r377067;
        return r377068;
}

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