Average Error: 2.0 → 1.4
Time: 9.1s
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 8.781993478759028 \cdot 10^{+119}:\\ \;\;\;\;a \cdot t + \mathsf{fma}\left(z \cdot a, b, \mathsf{fma}\left(y, z, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, b, t\right) \cdot a + \left(z \cdot y + x\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 8.781993478759028 \cdot 10^{+119}:\\
\;\;\;\;a \cdot t + \mathsf{fma}\left(z \cdot a, b, \mathsf{fma}\left(y, z, x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r12805187 = x;
        double r12805188 = y;
        double r12805189 = z;
        double r12805190 = r12805188 * r12805189;
        double r12805191 = r12805187 + r12805190;
        double r12805192 = t;
        double r12805193 = a;
        double r12805194 = r12805192 * r12805193;
        double r12805195 = r12805191 + r12805194;
        double r12805196 = r12805193 * r12805189;
        double r12805197 = b;
        double r12805198 = r12805196 * r12805197;
        double r12805199 = r12805195 + r12805198;
        return r12805199;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r12805200 = a;
        double r12805201 = 8.781993478759028e+119;
        bool r12805202 = r12805200 <= r12805201;
        double r12805203 = t;
        double r12805204 = r12805200 * r12805203;
        double r12805205 = z;
        double r12805206 = r12805205 * r12805200;
        double r12805207 = b;
        double r12805208 = y;
        double r12805209 = x;
        double r12805210 = fma(r12805208, r12805205, r12805209);
        double r12805211 = fma(r12805206, r12805207, r12805210);
        double r12805212 = r12805204 + r12805211;
        double r12805213 = fma(r12805205, r12805207, r12805203);
        double r12805214 = r12805213 * r12805200;
        double r12805215 = r12805205 * r12805208;
        double r12805216 = r12805215 + r12805209;
        double r12805217 = r12805214 + r12805216;
        double r12805218 = r12805202 ? r12805212 : r12805217;
        return r12805218;
}

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.0
Target0.4
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;z \lt -1.1820553527347888 \cdot 10^{+19}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.7589743188364287 \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 < 8.781993478759028e+119

    1. Initial program 1.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+1.5

      \[\leadsto \color{blue}{\left(x + y \cdot z\right) + \left(t \cdot a + \left(a \cdot z\right) \cdot b\right)}\]
    4. Simplified3.0

      \[\leadsto \left(x + y \cdot z\right) + \color{blue}{a \cdot \mathsf{fma}\left(z, b, t\right)}\]
    5. Using strategy rm
    6. Applied fma-udef3.0

      \[\leadsto \left(x + y \cdot z\right) + a \cdot \color{blue}{\left(z \cdot b + t\right)}\]
    7. Applied distribute-lft-in3.0

      \[\leadsto \left(x + y \cdot z\right) + \color{blue}{\left(a \cdot \left(z \cdot b\right) + a \cdot t\right)}\]
    8. Applied associate-+r+3.0

      \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + a \cdot \left(z \cdot b\right)\right) + a \cdot t}\]
    9. Simplified1.5

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

    if 8.781993478759028e+119 < a

    1. Initial program 7.0

      \[\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+7.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le 8.781993478759028 \cdot 10^{+119}:\\ \;\;\;\;a \cdot t + \mathsf{fma}\left(z \cdot a, b, \mathsf{fma}\left(y, z, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, b, t\right) \cdot a + \left(z \cdot y + x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 +o rules:numerics
(FPCore (x y z t a b)
  :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"

  :herbie-target
  (if (< z -1.1820553527347888e+19) (+ (* 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)))