Average Error: 1.9 → 0.2
Time: 16.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 -6.357410001287211 \cdot 10^{+38}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \mathbf{elif}\;b \le 2.9524094529077537 \cdot 10^{+72}:\\ \;\;\;\;\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 -6.357410001287211 \cdot 10^{+38}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\

\mathbf{elif}\;b \le 2.9524094529077537 \cdot 10^{+72}:\\
\;\;\;\;\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 r29294173 = x;
        double r29294174 = y;
        double r29294175 = z;
        double r29294176 = r29294174 * r29294175;
        double r29294177 = r29294173 + r29294176;
        double r29294178 = t;
        double r29294179 = a;
        double r29294180 = r29294178 * r29294179;
        double r29294181 = r29294177 + r29294180;
        double r29294182 = r29294179 * r29294175;
        double r29294183 = b;
        double r29294184 = r29294182 * r29294183;
        double r29294185 = r29294181 + r29294184;
        return r29294185;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r29294186 = b;
        double r29294187 = -6.357410001287211e+38;
        bool r29294188 = r29294186 <= r29294187;
        double r29294189 = a;
        double r29294190 = z;
        double r29294191 = r29294189 * r29294190;
        double r29294192 = r29294191 * r29294186;
        double r29294193 = x;
        double r29294194 = y;
        double r29294195 = r29294194 * r29294190;
        double r29294196 = r29294193 + r29294195;
        double r29294197 = t;
        double r29294198 = r29294189 * r29294197;
        double r29294199 = r29294196 + r29294198;
        double r29294200 = r29294192 + r29294199;
        double r29294201 = 2.9524094529077537e+72;
        bool r29294202 = r29294186 <= r29294201;
        double r29294203 = fma(r29294189, r29294186, r29294194);
        double r29294204 = fma(r29294190, r29294203, r29294193);
        double r29294205 = fma(r29294197, r29294189, r29294204);
        double r29294206 = r29294202 ? r29294205 : r29294200;
        double r29294207 = r29294188 ? r29294200 : r29294206;
        return r29294207;
}

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.2
\[\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 < -6.357410001287211e+38 or 2.9524094529077537e+72 < b

    1. Initial program 0.4

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

    if -6.357410001287211e+38 < b < 2.9524094529077537e+72

    1. Initial program 2.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.357410001287211 \cdot 10^{+38}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \mathbf{elif}\;b \le 2.9524094529077537 \cdot 10^{+72}:\\ \;\;\;\;\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 2019164 +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)))