Average Error: 2.1 → 0.1
Time: 4.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}\;a \le -5.6689298804501149 \cdot 10^{-54} \lor \neg \left(a \le 1.3083682113504501 \cdot 10^{-20}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\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}\;a \le -5.6689298804501149 \cdot 10^{-54} \lor \neg \left(a \le 1.3083682113504501 \cdot 10^{-20}\right):\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r565280 = x;
        double r565281 = y;
        double r565282 = z;
        double r565283 = r565281 * r565282;
        double r565284 = r565280 + r565283;
        double r565285 = t;
        double r565286 = a;
        double r565287 = r565285 * r565286;
        double r565288 = r565284 + r565287;
        double r565289 = r565286 * r565282;
        double r565290 = b;
        double r565291 = r565289 * r565290;
        double r565292 = r565288 + r565291;
        return r565292;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r565293 = a;
        double r565294 = -5.668929880450115e-54;
        bool r565295 = r565293 <= r565294;
        double r565296 = 1.3083682113504501e-20;
        bool r565297 = r565293 <= r565296;
        double r565298 = !r565297;
        bool r565299 = r565295 || r565298;
        double r565300 = x;
        double r565301 = y;
        double r565302 = z;
        double r565303 = r565301 * r565302;
        double r565304 = r565300 + r565303;
        double r565305 = t;
        double r565306 = r565305 * r565293;
        double r565307 = r565304 + r565306;
        double r565308 = b;
        double r565309 = r565302 * r565308;
        double r565310 = r565293 * r565309;
        double r565311 = 1.0;
        double r565312 = pow(r565310, r565311);
        double r565313 = r565307 + r565312;
        double r565314 = fma(r565293, r565308, r565301);
        double r565315 = fma(r565293, r565305, r565300);
        double r565316 = fma(r565314, r565302, r565315);
        double r565317 = r565299 ? r565313 : r565316;
        return r565317;
}

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.3
Herbie0.1
\[\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 a < -5.668929880450115e-54 or 1.3083682113504501e-20 < a

    1. Initial program 4.2

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied pow14.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot \color{blue}{{b}^{1}}\]
    4. Applied pow14.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot \color{blue}{{z}^{1}}\right) \cdot {b}^{1}\]
    5. Applied pow14.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\color{blue}{{a}^{1}} \cdot {z}^{1}\right) \cdot {b}^{1}\]
    6. Applied pow-prod-down4.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{{\left(a \cdot z\right)}^{1}} \cdot {b}^{1}\]
    7. Applied pow-prod-down4.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{{\left(\left(a \cdot z\right) \cdot b\right)}^{1}}\]
    8. Simplified0.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + {\color{blue}{\left(a \cdot \left(z \cdot b\right)\right)}}^{1}\]

    if -5.668929880450115e-54 < a < 1.3083682113504501e-20

    1. Initial program 0.5

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

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

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

Reproduce

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