Average Error: 2.1 → 1.7
Time: 16.1s
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 -5.97971639389373298 \cdot 10^{-155}:\\ \;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \mathsf{fma}\left(y, z, a \cdot t\right)\right) + \left(\sqrt[3]{\left(a \cdot z\right) \cdot b} \cdot \sqrt[3]{\left(a \cdot z\right) \cdot b}\right) \cdot \sqrt[3]{\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 -5.97971639389373298 \cdot 10^{-155}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x + \mathsf{fma}\left(y, z, a \cdot t\right)\right) + \left(\sqrt[3]{\left(a \cdot z\right) \cdot b} \cdot \sqrt[3]{\left(a \cdot z\right) \cdot b}\right) \cdot \sqrt[3]{\left(a \cdot z\right) \cdot b}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r735275 = x;
        double r735276 = y;
        double r735277 = z;
        double r735278 = r735276 * r735277;
        double r735279 = r735275 + r735278;
        double r735280 = t;
        double r735281 = a;
        double r735282 = r735280 * r735281;
        double r735283 = r735279 + r735282;
        double r735284 = r735281 * r735277;
        double r735285 = b;
        double r735286 = r735284 * r735285;
        double r735287 = r735283 + r735286;
        return r735287;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r735288 = a;
        double r735289 = -5.979716393893733e-155;
        bool r735290 = r735288 <= r735289;
        double r735291 = z;
        double r735292 = b;
        double r735293 = t;
        double r735294 = fma(r735291, r735292, r735293);
        double r735295 = y;
        double r735296 = x;
        double r735297 = fma(r735295, r735291, r735296);
        double r735298 = fma(r735288, r735294, r735297);
        double r735299 = r735288 * r735293;
        double r735300 = fma(r735295, r735291, r735299);
        double r735301 = r735296 + r735300;
        double r735302 = r735288 * r735291;
        double r735303 = r735302 * r735292;
        double r735304 = cbrt(r735303);
        double r735305 = r735304 * r735304;
        double r735306 = r735305 * r735304;
        double r735307 = r735301 + r735306;
        double r735308 = r735290 ? r735298 : r735307;
        return r735308;
}

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

Original2.1
Target0.3
Herbie1.7
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888000:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.75897431883642871 \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 < -5.979716393893733e-155

    1. Initial program 2.5

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

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

    if -5.979716393893733e-155 < a

    1. Initial program 1.9

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-+l+1.9

      \[\leadsto \color{blue}{\left(x + \left(y \cdot z + t \cdot a\right)\right)} + \left(a \cdot z\right) \cdot b\]
    4. Simplified1.9

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

      \[\leadsto \left(x + \mathsf{fma}\left(y, z, a \cdot t\right)\right) + \color{blue}{\left(\sqrt[3]{\left(a \cdot z\right) \cdot b} \cdot \sqrt[3]{\left(a \cdot z\right) \cdot b}\right) \cdot \sqrt[3]{\left(a \cdot z\right) \cdot b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.7

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

Reproduce

herbie shell --seed 2020043 +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)))