Average Error: 1.9 → 0.3
Time: 18.5s
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}\;b \le -5.754212541607782 \cdot 10^{-35}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \mathbf{elif}\;b \le 2.1429854807890883 \cdot 10^{+18}:\\ \;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \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}\;b \le -5.754212541607782 \cdot 10^{-35}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\

\mathbf{elif}\;b \le 2.1429854807890883 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r27044311 = x;
        double r27044312 = y;
        double r27044313 = z;
        double r27044314 = r27044312 * r27044313;
        double r27044315 = r27044311 + r27044314;
        double r27044316 = t;
        double r27044317 = a;
        double r27044318 = r27044316 * r27044317;
        double r27044319 = r27044315 + r27044318;
        double r27044320 = r27044317 * r27044313;
        double r27044321 = b;
        double r27044322 = r27044320 * r27044321;
        double r27044323 = r27044319 + r27044322;
        return r27044323;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r27044324 = b;
        double r27044325 = -5.754212541607782e-35;
        bool r27044326 = r27044324 <= r27044325;
        double r27044327 = a;
        double r27044328 = z;
        double r27044329 = r27044327 * r27044328;
        double r27044330 = r27044329 * r27044324;
        double r27044331 = x;
        double r27044332 = y;
        double r27044333 = r27044332 * r27044328;
        double r27044334 = r27044331 + r27044333;
        double r27044335 = t;
        double r27044336 = r27044327 * r27044335;
        double r27044337 = r27044334 + r27044336;
        double r27044338 = r27044330 + r27044337;
        double r27044339 = 2.1429854807890883e+18;
        bool r27044340 = r27044324 <= r27044339;
        double r27044341 = fma(r27044327, r27044324, r27044332);
        double r27044342 = fma(r27044328, r27044341, r27044331);
        double r27044343 = fma(r27044335, r27044327, r27044342);
        double r27044344 = r27044340 ? r27044343 : r27044338;
        double r27044345 = r27044326 ? r27044338 : r27044344;
        return r27044345;
}

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.4
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;z \lt -1.1820553527347888 \cdot 10^{+19}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.7589743188364287 \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 b < -5.754212541607782e-35 or 2.1429854807890883e+18 < b

    1. Initial program 0.5

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]

    if -5.754212541607782e-35 < b < 2.1429854807890883e+18

    1. Initial program 3.2

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

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

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

Reproduce

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

  :herbie-target
  (if (< z -1.1820553527347888e+19) (+ (* 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)))