Average Error: 0.1 → 0.1
Time: 27.6s
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 r333208 = x;
        double r333209 = y;
        double r333210 = r333208 * r333209;
        double r333211 = z;
        double r333212 = r333211 * r333211;
        double r333213 = r333210 + r333212;
        double r333214 = r333213 + r333212;
        double r333215 = r333214 + r333212;
        return r333215;
}

double f(double x, double y, double z) {
        double r333216 = y;
        double r333217 = x;
        double r333218 = z;
        double r333219 = 3.0;
        double r333220 = r333219 * r333218;
        double r333221 = r333218 * r333220;
        double r333222 = fma(r333216, r333217, r333221);
        return r333222;
}

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 pow10.1

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

    \[\leadsto \mathsf{fma}\left(y, x, 3 \cdot \left(\color{blue}{{z}^{1}} \cdot {z}^{1}\right)\right)\]
  6. Applied pow-prod-down0.1

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

    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{{3}^{1}} \cdot {\left(z \cdot z\right)}^{1}\right)\]
  8. Applied pow-prod-down0.1

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

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

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

Reproduce

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