Average Error: 0.1 → 0.1
Time: 14.4s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 3\right)\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 3\right)\right)
double f(double x, double y) {
        double r21228196 = x;
        double r21228197 = r21228196 * r21228196;
        double r21228198 = y;
        double r21228199 = r21228198 * r21228198;
        double r21228200 = r21228197 + r21228199;
        double r21228201 = r21228200 + r21228199;
        double r21228202 = r21228201 + r21228199;
        return r21228202;
}

double f(double x, double y) {
        double r21228203 = x;
        double r21228204 = y;
        double r21228205 = 3.0;
        double r21228206 = r21228204 * r21228205;
        double r21228207 = r21228204 * r21228206;
        double r21228208 = fma(r21228203, r21228203, r21228207);
        return r21228208;
}

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

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

Reproduce

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