Average Error: 1.9 → 1.3
Time: 10.4s
Precision: 64
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.15879112181343211934394488782529501731 \cdot 10^{-117}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \end{array}\]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
\mathbf{if}\;a \le -1.15879112181343211934394488782529501731 \cdot 10^{-117}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r708875 = x;
        double r708876 = y;
        double r708877 = z;
        double r708878 = r708876 * r708877;
        double r708879 = r708875 + r708878;
        double r708880 = t;
        double r708881 = a;
        double r708882 = r708880 * r708881;
        double r708883 = r708879 + r708882;
        double r708884 = r708881 * r708877;
        double r708885 = b;
        double r708886 = r708884 * r708885;
        double r708887 = r708883 + r708886;
        return r708887;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r708888 = a;
        double r708889 = -1.1587911218134321e-117;
        bool r708890 = r708888 <= r708889;
        double r708891 = z;
        double r708892 = y;
        double r708893 = b;
        double r708894 = t;
        double r708895 = fma(r708891, r708893, r708894);
        double r708896 = x;
        double r708897 = fma(r708895, r708888, r708896);
        double r708898 = fma(r708891, r708892, r708897);
        double r708899 = r708892 * r708891;
        double r708900 = r708896 + r708899;
        double r708901 = r708894 * r708888;
        double r708902 = r708900 + r708901;
        double r708903 = r708888 * r708891;
        double r708904 = r708903 * r708893;
        double r708905 = r708902 + r708904;
        double r708906 = r708890 ? r708898 : r708905;
        return r708906;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original1.9
Target0.2
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888128:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.758974318836428710669076838657752600596 \cdot 10^{-122}:\\ \;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if a < -1.1587911218134321e-117

    1. Initial program 2.9

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Simplified0.8

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

    if -1.1587911218134321e-117 < a

    1. Initial program 1.5

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.15879112181343211934394488782529501731 \cdot 10^{-117}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \end{array}\]

Reproduce

herbie shell --seed 2019350 +o rules:numerics
(FPCore (x y z t a b)
  :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
  :precision binary64

  :herbie-target
  (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

  (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))