Average Error: 1.8 → 1.3
Time: 14.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}\;z \le -1.240303802171897282819320165004435633224 \cdot 10^{-119}:\\ \;\;\;\;\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 + z \cdot y\right) + t \cdot a\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}\;z \le -1.240303802171897282819320165004435633224 \cdot 10^{-119}:\\
\;\;\;\;\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 + z \cdot y\right) + t \cdot a\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r488190 = x;
        double r488191 = y;
        double r488192 = z;
        double r488193 = r488191 * r488192;
        double r488194 = r488190 + r488193;
        double r488195 = t;
        double r488196 = a;
        double r488197 = r488195 * r488196;
        double r488198 = r488194 + r488197;
        double r488199 = r488196 * r488192;
        double r488200 = b;
        double r488201 = r488199 * r488200;
        double r488202 = r488198 + r488201;
        return r488202;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r488203 = z;
        double r488204 = -1.2403038021718973e-119;
        bool r488205 = r488203 <= r488204;
        double r488206 = t;
        double r488207 = a;
        double r488208 = b;
        double r488209 = y;
        double r488210 = fma(r488207, r488208, r488209);
        double r488211 = x;
        double r488212 = fma(r488203, r488210, r488211);
        double r488213 = fma(r488206, r488207, r488212);
        double r488214 = r488207 * r488203;
        double r488215 = r488214 * r488208;
        double r488216 = r488203 * r488209;
        double r488217 = r488211 + r488216;
        double r488218 = r488206 * r488207;
        double r488219 = r488217 + r488218;
        double r488220 = r488215 + r488219;
        double r488221 = r488205 ? r488213 : r488220;
        return r488221;
}

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.8
Target0.3
Herbie1.3
\[\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 2 regimes
  2. if z < -1.2403038021718973e-119

    1. Initial program 2.9

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

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

    if -1.2403038021718973e-119 < z

    1. Initial program 1.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.240303802171897282819320165004435633224 \cdot 10^{-119}:\\ \;\;\;\;\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 + z \cdot y\right) + t \cdot a\right)\\ \end{array}\]

Reproduce

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