Average Error: 0.1 → 0.1
Time: 9.9s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(y, x, z \cdot \left(3 \cdot z\right)\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(y, x, z \cdot \left(3 \cdot z\right)\right)
double f(double x, double y, double z) {
        double r518188 = x;
        double r518189 = y;
        double r518190 = r518188 * r518189;
        double r518191 = z;
        double r518192 = r518191 * r518191;
        double r518193 = r518190 + r518192;
        double r518194 = r518193 + r518192;
        double r518195 = r518194 + r518192;
        return r518195;
}

double f(double x, double y, double z) {
        double r518196 = y;
        double r518197 = x;
        double r518198 = z;
        double r518199 = 3.0;
        double r518200 = r518199 * r518198;
        double r518201 = r518198 * r518200;
        double r518202 = fma(r518196, r518197, r518201);
        return r518202;
}

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. Using strategy rm
  4. Applied *-un-lft-identity0.1

    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(1 \cdot 3\right)} \cdot \left(z \cdot z\right)\right)\]
  5. Applied associate-*l*0.1

    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{1 \cdot \left(3 \cdot \left(z \cdot z\right)\right)}\right)\]
  6. Simplified0.1

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

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

Reproduce

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