Average Error: 1.9 → 1.2
Time: 8.0s
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(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, 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.67032308676182466 \cdot 10^{79}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, 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 r573097 = x;
        double r573098 = y;
        double r573099 = z;
        double r573100 = r573098 * r573099;
        double r573101 = r573097 + r573100;
        double r573102 = t;
        double r573103 = a;
        double r573104 = r573102 * r573103;
        double r573105 = r573101 + r573104;
        double r573106 = r573103 * r573099;
        double r573107 = b;
        double r573108 = r573106 * r573107;
        double r573109 = r573105 + r573108;
        return r573109;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r573110 = a;
        double r573111 = -1.6703230867618247e+79;
        bool r573112 = r573110 <= r573111;
        double r573113 = z;
        double r573114 = b;
        double r573115 = t;
        double r573116 = fma(r573113, r573114, r573115);
        double r573117 = y;
        double r573118 = x;
        double r573119 = fma(r573117, r573113, r573118);
        double r573120 = fma(r573110, r573116, r573119);
        double r573121 = r573117 * r573113;
        double r573122 = r573118 + r573121;
        double r573123 = r573115 * r573110;
        double r573124 = r573122 + r573123;
        double r573125 = r573110 * r573113;
        double r573126 = r573125 * r573114;
        double r573127 = r573124 + r573126;
        double r573128 = r573112 ? r573120 : r573127;
        return r573128;
}

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. Simplified0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, x\right)\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\]
  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(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, 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 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)))