Average Error: 0.1 → 0.1
Time: 23.0s
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 r410972 = x;
        double r410973 = r410972 * r410972;
        double r410974 = y;
        double r410975 = r410974 * r410974;
        double r410976 = r410973 + r410975;
        double r410977 = r410976 + r410975;
        double r410978 = r410977 + r410975;
        return r410978;
}

double f(double x, double y) {
        double r410979 = x;
        double r410980 = 3.0;
        double r410981 = y;
        double r410982 = r410981 * r410981;
        double r410983 = r410980 * r410982;
        double r410984 = fma(r410979, r410979, r410983);
        return r410984;
}

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. Using strategy rm
  4. Applied pow10.1

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

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

Reproduce

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

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

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