Average Error: 1.9 → 0.5
Time: 10.7s
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}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le -1.024965538038057030979250652572253384945 \cdot 10^{293} \lor \neg \left(\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le 8.158533006906759738250660622987895011485 \cdot 10^{303}\right):\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, 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}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le -1.024965538038057030979250652572253384945 \cdot 10^{293} \lor \neg \left(\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le 8.158533006906759738250660622987895011485 \cdot 10^{303}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, 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 r422146 = x;
        double r422147 = y;
        double r422148 = z;
        double r422149 = r422147 * r422148;
        double r422150 = r422146 + r422149;
        double r422151 = t;
        double r422152 = a;
        double r422153 = r422151 * r422152;
        double r422154 = r422150 + r422153;
        double r422155 = r422152 * r422148;
        double r422156 = b;
        double r422157 = r422155 * r422156;
        double r422158 = r422154 + r422157;
        return r422158;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r422159 = x;
        double r422160 = y;
        double r422161 = z;
        double r422162 = r422160 * r422161;
        double r422163 = r422159 + r422162;
        double r422164 = t;
        double r422165 = a;
        double r422166 = r422164 * r422165;
        double r422167 = r422163 + r422166;
        double r422168 = r422165 * r422161;
        double r422169 = b;
        double r422170 = r422168 * r422169;
        double r422171 = r422167 + r422170;
        double r422172 = -1.024965538038057e+293;
        bool r422173 = r422171 <= r422172;
        double r422174 = 8.15853300690676e+303;
        bool r422175 = r422171 <= r422174;
        double r422176 = !r422175;
        bool r422177 = r422173 || r422176;
        double r422178 = fma(r422161, r422169, r422164);
        double r422179 = fma(r422178, r422165, r422159);
        double r422180 = fma(r422161, r422160, r422179);
        double r422181 = r422177 ? r422180 : r422171;
        return r422181;
}

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.5
\[\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 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)) < -1.024965538038057e+293 or 8.15853300690676e+303 < (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))

    1. Initial program 26.7

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

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

    if -1.024965538038057e+293 < (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)) < 8.15853300690676e+303

    1. Initial program 0.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 simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le -1.024965538038057030979250652572253384945 \cdot 10^{293} \lor \neg \left(\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le 8.158533006906759738250660622987895011485 \cdot 10^{303}\right):\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, 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 2019325 +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)))