Average Error: 2.1 → 2.1
Time: 3.4s
Precision: 64
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
\[\left(x + y \cdot z\right) + \mathsf{fma}\left(t, a, \left(a \cdot z\right) \cdot b\right)\]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\left(x + y \cdot z\right) + \mathsf{fma}\left(t, a, \left(a \cdot z\right) \cdot b\right)
double f(double x, double y, double z, double t, double a, double b) {
        double r594178 = x;
        double r594179 = y;
        double r594180 = z;
        double r594181 = r594179 * r594180;
        double r594182 = r594178 + r594181;
        double r594183 = t;
        double r594184 = a;
        double r594185 = r594183 * r594184;
        double r594186 = r594182 + r594185;
        double r594187 = r594184 * r594180;
        double r594188 = b;
        double r594189 = r594187 * r594188;
        double r594190 = r594186 + r594189;
        return r594190;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r594191 = x;
        double r594192 = y;
        double r594193 = z;
        double r594194 = r594192 * r594193;
        double r594195 = r594191 + r594194;
        double r594196 = t;
        double r594197 = a;
        double r594198 = r594197 * r594193;
        double r594199 = b;
        double r594200 = r594198 * r594199;
        double r594201 = fma(r594196, r594197, r594200);
        double r594202 = r594195 + r594201;
        return r594202;
}

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.5
Herbie2.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. Initial program 2.1

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

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

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

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

Reproduce

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