Average Error: 2.0 → 0.3
Time: 3.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}\;z \le -2.1907779427427348 \cdot 10^{65} \lor \neg \left(z \le 7.3334928750494001 \cdot 10^{-42}\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 -2.1907779427427348 \cdot 10^{65} \lor \neg \left(z \le 7.3334928750494001 \cdot 10^{-42}\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 r637032 = x;
        double r637033 = y;
        double r637034 = z;
        double r637035 = r637033 * r637034;
        double r637036 = r637032 + r637035;
        double r637037 = t;
        double r637038 = a;
        double r637039 = r637037 * r637038;
        double r637040 = r637036 + r637039;
        double r637041 = r637038 * r637034;
        double r637042 = b;
        double r637043 = r637041 * r637042;
        double r637044 = r637040 + r637043;
        return r637044;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r637045 = z;
        double r637046 = -2.190777942742735e+65;
        bool r637047 = r637045 <= r637046;
        double r637048 = 7.3334928750494e-42;
        bool r637049 = r637045 <= r637048;
        double r637050 = !r637049;
        bool r637051 = r637047 || r637050;
        double r637052 = a;
        double r637053 = b;
        double r637054 = y;
        double r637055 = fma(r637052, r637053, r637054);
        double r637056 = t;
        double r637057 = x;
        double r637058 = fma(r637052, r637056, r637057);
        double r637059 = fma(r637055, r637045, r637058);
        double r637060 = r637054 * r637045;
        double r637061 = r637057 + r637060;
        double r637062 = r637056 * r637052;
        double r637063 = r637061 + r637062;
        double r637064 = r637045 * r637053;
        double r637065 = r637052 * r637064;
        double r637066 = r637063 + r637065;
        double r637067 = r637051 ? r637059 : r637066;
        return r637067;
}

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.3
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 < -2.190777942742735e+65 or 7.3334928750494e-42 < z

    1. Initial program 4.8

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

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

    if -2.190777942742735e+65 < z < 7.3334928750494e-42

    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 -2.1907779427427348 \cdot 10^{65} \lor \neg \left(z \le 7.3334928750494001 \cdot 10^{-42}\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 2020046 +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)))