Average Error: 0.1 → 0.1
Time: 11.2s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)
double f(double x, double y) {
        double r35449058 = x;
        double r35449059 = r35449058 * r35449058;
        double r35449060 = y;
        double r35449061 = r35449060 * r35449060;
        double r35449062 = r35449059 + r35449061;
        double r35449063 = r35449062 + r35449061;
        double r35449064 = r35449063 + r35449061;
        return r35449064;
}

double f(double x, double y) {
        double r35449065 = x;
        double r35449066 = 3.0;
        double r35449067 = y;
        double r35449068 = r35449067 * r35449067;
        double r35449069 = r35449066 * r35449068;
        double r35449070 = fma(r35449065, r35449065, r35449069);
        return r35449070;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.1

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, E"

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

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