Average Error: 2.1 → 0.4
Time: 15.8s
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}\;a \le -4.539344998412310163216098726290806926989 \cdot 10^{-29} \lor \neg \left(a \le 6.32466299026394733247098424868204187227 \cdot 10^{118}\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}\;a \le -4.539344998412310163216098726290806926989 \cdot 10^{-29} \lor \neg \left(a \le 6.32466299026394733247098424868204187227 \cdot 10^{118}\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 r617493 = x;
        double r617494 = y;
        double r617495 = z;
        double r617496 = r617494 * r617495;
        double r617497 = r617493 + r617496;
        double r617498 = t;
        double r617499 = a;
        double r617500 = r617498 * r617499;
        double r617501 = r617497 + r617500;
        double r617502 = r617499 * r617495;
        double r617503 = b;
        double r617504 = r617502 * r617503;
        double r617505 = r617501 + r617504;
        return r617505;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r617506 = a;
        double r617507 = -4.53934499841231e-29;
        bool r617508 = r617506 <= r617507;
        double r617509 = 6.324662990263947e+118;
        bool r617510 = r617506 <= r617509;
        double r617511 = !r617510;
        bool r617512 = r617508 || r617511;
        double r617513 = z;
        double r617514 = y;
        double r617515 = b;
        double r617516 = t;
        double r617517 = fma(r617513, r617515, r617516);
        double r617518 = x;
        double r617519 = fma(r617517, r617506, r617518);
        double r617520 = fma(r617513, r617514, r617519);
        double r617521 = r617514 * r617513;
        double r617522 = r617518 + r617521;
        double r617523 = r617516 * r617506;
        double r617524 = r617522 + r617523;
        double r617525 = r617506 * r617513;
        double r617526 = r617525 * r617515;
        double r617527 = r617524 + r617526;
        double r617528 = r617512 ? r617520 : r617527;
        return r617528;
}

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.1
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 a < -4.53934499841231e-29 or 6.324662990263947e+118 < a

    1. Initial program 5.6

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

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

    if -4.53934499841231e-29 < a < 6.324662990263947e+118

    1. Initial program 0.6

      \[\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}\;a \le -4.539344998412310163216098726290806926989 \cdot 10^{-29} \lor \neg \left(a \le 6.32466299026394733247098424868204187227 \cdot 10^{118}\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 2019304 +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)))