Average Error: 0.1 → 0.1
Time: 4.7s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)
double f(double x, double y, double z) {
        double r459137 = x;
        double r459138 = y;
        double r459139 = r459137 * r459138;
        double r459140 = z;
        double r459141 = r459140 * r459140;
        double r459142 = r459139 + r459141;
        double r459143 = r459142 + r459141;
        double r459144 = r459143 + r459141;
        return r459144;
}

double f(double x, double y, double z) {
        double r459145 = 3.0;
        double r459146 = z;
        double r459147 = r459146 * r459146;
        double r459148 = x;
        double r459149 = y;
        double r459150 = r459148 * r459149;
        double r459151 = fma(r459145, r459147, r459150);
        return r459151;
}

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(3, z \cdot z, x \cdot y\right)}\]
  3. Final simplification0.1

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

Reproduce

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