Average Error: 10.8 → 0.6
Time: 30.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.3968702923314023 \cdot 10^{-55} \lor \neg \left(t \le 5.61052099025827211 \cdot 10^{-96}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - z\right) \cdot t}{a - z} + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;t \le -1.3968702923314023 \cdot 10^{-55} \lor \neg \left(t \le 5.61052099025827211 \cdot 10^{-96}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r394978 = x;
        double r394979 = y;
        double r394980 = z;
        double r394981 = r394979 - r394980;
        double r394982 = t;
        double r394983 = r394981 * r394982;
        double r394984 = a;
        double r394985 = r394984 - r394980;
        double r394986 = r394983 / r394985;
        double r394987 = r394978 + r394986;
        return r394987;
}

double f(double x, double y, double z, double t, double a) {
        double r394988 = t;
        double r394989 = -1.3968702923314023e-55;
        bool r394990 = r394988 <= r394989;
        double r394991 = 5.610520990258272e-96;
        bool r394992 = r394988 <= r394991;
        double r394993 = !r394992;
        bool r394994 = r394990 || r394993;
        double r394995 = y;
        double r394996 = z;
        double r394997 = r394995 - r394996;
        double r394998 = a;
        double r394999 = r394998 - r394996;
        double r395000 = r394997 / r394999;
        double r395001 = x;
        double r395002 = fma(r395000, r394988, r395001);
        double r395003 = r394997 * r394988;
        double r395004 = r395003 / r394999;
        double r395005 = r395004 + r395001;
        double r395006 = r394994 ? r395002 : r395005;
        return r395006;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.8
Target0.6
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;t \lt -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.9110949887586375 \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 t < -1.3968702923314023e-55 or 5.610520990258272e-96 < t

    1. Initial program 18.2

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

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

    if -1.3968702923314023e-55 < t < 5.610520990258272e-96

    1. Initial program 0.3

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.3968702923314023 \cdot 10^{-55} \lor \neg \left(t \le 5.61052099025827211 \cdot 10^{-96}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - z\right) \cdot t}{a - z} + x\\ \end{array}\]

Reproduce

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

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