Average Error: 1.9 → 1.7
Time: 17.6s
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 -2.528529148805566551931423270735609161364 \cdot 10^{172}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(z, b, t\right) + \left(x + y \cdot z\right)\\ \mathbf{elif}\;b \le 7.580017239038191661519104654564671221574 \cdot 10^{128}:\\ \;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a \cdot z\right) + \left(t \cdot a + \left(x + y \cdot z\right)\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 -2.528529148805566551931423270735609161364 \cdot 10^{172}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(z, b, t\right) + \left(x + y \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r27165129 = x;
        double r27165130 = y;
        double r27165131 = z;
        double r27165132 = r27165130 * r27165131;
        double r27165133 = r27165129 + r27165132;
        double r27165134 = t;
        double r27165135 = a;
        double r27165136 = r27165134 * r27165135;
        double r27165137 = r27165133 + r27165136;
        double r27165138 = r27165135 * r27165131;
        double r27165139 = b;
        double r27165140 = r27165138 * r27165139;
        double r27165141 = r27165137 + r27165140;
        return r27165141;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r27165142 = b;
        double r27165143 = -2.5285291488055666e+172;
        bool r27165144 = r27165142 <= r27165143;
        double r27165145 = a;
        double r27165146 = z;
        double r27165147 = t;
        double r27165148 = fma(r27165146, r27165142, r27165147);
        double r27165149 = r27165145 * r27165148;
        double r27165150 = x;
        double r27165151 = y;
        double r27165152 = r27165151 * r27165146;
        double r27165153 = r27165150 + r27165152;
        double r27165154 = r27165149 + r27165153;
        double r27165155 = 7.580017239038192e+128;
        bool r27165156 = r27165142 <= r27165155;
        double r27165157 = fma(r27165145, r27165142, r27165151);
        double r27165158 = fma(r27165146, r27165157, r27165150);
        double r27165159 = fma(r27165147, r27165145, r27165158);
        double r27165160 = r27165145 * r27165146;
        double r27165161 = r27165142 * r27165160;
        double r27165162 = r27165147 * r27165145;
        double r27165163 = r27165162 + r27165153;
        double r27165164 = r27165161 + r27165163;
        double r27165165 = r27165156 ? r27165159 : r27165164;
        double r27165166 = r27165144 ? r27165154 : r27165165;
        return r27165166;
}

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.7
\[\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 3 regimes
  2. if b < -2.5285291488055666e+172

    1. Initial program 1.2

      \[\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.2

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

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

    if -2.5285291488055666e+172 < b < 7.580017239038192e+128

    1. Initial program 2.2

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

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

    if 7.580017239038192e+128 < b

    1. Initial program 0.8

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

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

Reproduce

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