Average Error: 2.1 → 0.3
Time: 4.6s
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 -5.277355753028798 \cdot 10^{76} \lor \neg \left(z \le 1.52075545580715531 \cdot 10^{-27}\right):\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(z \cdot b\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 -5.277355753028798 \cdot 10^{76} \lor \neg \left(z \le 1.52075545580715531 \cdot 10^{-27}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(z \cdot b\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r584775 = x;
        double r584776 = y;
        double r584777 = z;
        double r584778 = r584776 * r584777;
        double r584779 = r584775 + r584778;
        double r584780 = t;
        double r584781 = a;
        double r584782 = r584780 * r584781;
        double r584783 = r584779 + r584782;
        double r584784 = r584781 * r584777;
        double r584785 = b;
        double r584786 = r584784 * r584785;
        double r584787 = r584783 + r584786;
        return r584787;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r584788 = z;
        double r584789 = -5.277355753028798e+76;
        bool r584790 = r584788 <= r584789;
        double r584791 = 1.5207554558071553e-27;
        bool r584792 = r584788 <= r584791;
        double r584793 = !r584792;
        bool r584794 = r584790 || r584793;
        double r584795 = a;
        double r584796 = b;
        double r584797 = y;
        double r584798 = fma(r584795, r584796, r584797);
        double r584799 = t;
        double r584800 = x;
        double r584801 = fma(r584795, r584799, r584800);
        double r584802 = fma(r584798, r584788, r584801);
        double r584803 = r584797 * r584788;
        double r584804 = r584800 + r584803;
        double r584805 = r584799 * r584795;
        double r584806 = r584804 + r584805;
        double r584807 = r584788 * r584796;
        double r584808 = r584795 * r584807;
        double r584809 = r584806 + r584808;
        double r584810 = r584794 ? r584802 : r584809;
        return r584810;
}

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.3
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888000:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.75897431883642871 \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 < -5.277355753028798e+76 or 1.5207554558071553e-27 < z

    1. Initial program 5.5

      \[\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(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)}\]

    if -5.277355753028798e+76 < z < 1.5207554558071553e-27

    1. Initial program 0.5

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*0.3

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{a \cdot \left(z \cdot b\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.277355753028798 \cdot 10^{76} \lor \neg \left(z \le 1.52075545580715531 \cdot 10^{-27}\right):\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(z \cdot b\right)\\ \end{array}\]

Reproduce

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