Average Error: 0.1 → 0.1
Time: 15.7s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(3, {z}^{2}, y \cdot x\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(3, {z}^{2}, y \cdot x\right)
double f(double x, double y, double z) {
        double r361912 = x;
        double r361913 = y;
        double r361914 = r361912 * r361913;
        double r361915 = z;
        double r361916 = r361915 * r361915;
        double r361917 = r361914 + r361916;
        double r361918 = r361917 + r361916;
        double r361919 = r361918 + r361916;
        return r361919;
}

double f(double x, double y, double z) {
        double r361920 = 3.0;
        double r361921 = z;
        double r361922 = 2.0;
        double r361923 = pow(r361921, r361922);
        double r361924 = y;
        double r361925 = x;
        double r361926 = r361924 * r361925;
        double r361927 = fma(r361920, r361923, r361926);
        return r361927;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(3 \cdot z\right) \cdot z + y \cdot x\]

Derivation

  1. Initial program 0.1

    \[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, 3 \cdot \left(z \cdot z\right)\right)}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot {z}^{2} + x \cdot y}\]
  4. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, {z}^{2}, y \cdot x\right)}\]
  5. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(3, {z}^{2}, y \cdot x\right)\]

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (+ (* (* 3 z) z) (* y x))

  (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))