Average Error: 1.9 → 1.2
Time: 4.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 -1.67032308676182466 \cdot 10^{79}:\\ \;\;\;\;\mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\right) + a \cdot \left(z \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\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.67032308676182466 \cdot 10^{79}:\\
\;\;\;\;\mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\right) + a \cdot \left(z \cdot b\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\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 r652371 = x;
        double r652372 = y;
        double r652373 = z;
        double r652374 = r652372 * r652373;
        double r652375 = r652371 + r652374;
        double r652376 = t;
        double r652377 = a;
        double r652378 = r652376 * r652377;
        double r652379 = r652375 + r652378;
        double r652380 = r652377 * r652373;
        double r652381 = b;
        double r652382 = r652380 * r652381;
        double r652383 = r652379 + r652382;
        return r652383;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r652384 = a;
        double r652385 = -1.6703230867618247e+79;
        bool r652386 = r652384 <= r652385;
        double r652387 = y;
        double r652388 = z;
        double r652389 = t;
        double r652390 = x;
        double r652391 = fma(r652384, r652389, r652390);
        double r652392 = fma(r652387, r652388, r652391);
        double r652393 = b;
        double r652394 = r652388 * r652393;
        double r652395 = r652384 * r652394;
        double r652396 = r652392 + r652395;
        double r652397 = r652384 * r652388;
        double r652398 = r652397 * r652393;
        double r652399 = r652392 + r652398;
        double r652400 = r652386 ? r652396 : r652399;
        return r652400;
}

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.3
Herbie1.2
\[\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 < -1.6703230867618247e+79

    1. Initial program 6.2

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Taylor expanded around inf 6.2

      \[\leadsto \color{blue}{\left(z \cdot y + \left(x + a \cdot t\right)\right)} + \left(a \cdot z\right) \cdot b\]
    3. Simplified6.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\right)} + \left(a \cdot z\right) \cdot b\]
    4. Using strategy rm
    5. Applied associate-*l*0.1

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

    if -1.6703230867618247e+79 < a

    1. Initial program 1.3

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Taylor expanded around inf 1.3

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

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

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

Reproduce

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