Average Error: 2.2 → 0.4
Time: 15.9s
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 = -\infty \lor \neg \left(\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le 5.116019414478908543360651182801591114306 \cdot 10^{293}\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 = -\infty \lor \neg \left(\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le 5.116019414478908543360651182801591114306 \cdot 10^{293}\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 r1074448 = x;
        double r1074449 = y;
        double r1074450 = z;
        double r1074451 = r1074449 * r1074450;
        double r1074452 = r1074448 + r1074451;
        double r1074453 = t;
        double r1074454 = a;
        double r1074455 = r1074453 * r1074454;
        double r1074456 = r1074452 + r1074455;
        double r1074457 = r1074454 * r1074450;
        double r1074458 = b;
        double r1074459 = r1074457 * r1074458;
        double r1074460 = r1074456 + r1074459;
        return r1074460;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1074461 = x;
        double r1074462 = y;
        double r1074463 = z;
        double r1074464 = r1074462 * r1074463;
        double r1074465 = r1074461 + r1074464;
        double r1074466 = t;
        double r1074467 = a;
        double r1074468 = r1074466 * r1074467;
        double r1074469 = r1074465 + r1074468;
        double r1074470 = r1074467 * r1074463;
        double r1074471 = b;
        double r1074472 = r1074470 * r1074471;
        double r1074473 = r1074469 + r1074472;
        double r1074474 = -inf.0;
        bool r1074475 = r1074473 <= r1074474;
        double r1074476 = 5.1160194144789085e+293;
        bool r1074477 = r1074473 <= r1074476;
        double r1074478 = !r1074477;
        bool r1074479 = r1074475 || r1074478;
        double r1074480 = fma(r1074463, r1074471, r1074466);
        double r1074481 = fma(r1074480, r1074467, r1074461);
        double r1074482 = fma(r1074463, r1074462, r1074481);
        double r1074483 = r1074479 ? r1074482 : r1074473;
        return r1074483;
}

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

Original2.2
Target0.4
Herbie0.4
\[\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)) < -inf.0 or 5.1160194144789085e+293 < (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))

    1. Initial program 34.0

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

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

    if -inf.0 < (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)) < 5.1160194144789085e+293

    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.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b = -\infty \lor \neg \left(\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \le 5.116019414478908543360651182801591114306 \cdot 10^{293}\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 2019303 +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.75897431883642871e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

  (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))