Average Error: 1.9 → 0.5
Time: 11.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}\;\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 r467063 = x;
        double r467064 = y;
        double r467065 = z;
        double r467066 = r467064 * r467065;
        double r467067 = r467063 + r467066;
        double r467068 = t;
        double r467069 = a;
        double r467070 = r467068 * r467069;
        double r467071 = r467067 + r467070;
        double r467072 = r467069 * r467065;
        double r467073 = b;
        double r467074 = r467072 * r467073;
        double r467075 = r467071 + r467074;
        return r467075;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r467076 = x;
        double r467077 = y;
        double r467078 = z;
        double r467079 = r467077 * r467078;
        double r467080 = r467076 + r467079;
        double r467081 = t;
        double r467082 = a;
        double r467083 = r467081 * r467082;
        double r467084 = r467080 + r467083;
        double r467085 = r467082 * r467078;
        double r467086 = b;
        double r467087 = r467085 * r467086;
        double r467088 = r467084 + r467087;
        double r467089 = -1.024965538038057e+293;
        bool r467090 = r467088 <= r467089;
        double r467091 = 8.15853300690676e+303;
        bool r467092 = r467088 <= r467091;
        double r467093 = !r467092;
        bool r467094 = r467090 || r467093;
        double r467095 = fma(r467078, r467086, r467081);
        double r467096 = fma(r467095, r467082, r467076);
        double r467097 = fma(r467078, r467077, r467096);
        double r467098 = r467094 ? r467097 : r467088;
        return r467098;
}

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)))