Average Error: 0.1 → 0.1
Time: 54.6s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \left(3 \cdot y\right) \cdot y\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(3 \cdot y\right) \cdot y\right)
double f(double x, double y) {
        double r20449198 = x;
        double r20449199 = r20449198 * r20449198;
        double r20449200 = y;
        double r20449201 = r20449200 * r20449200;
        double r20449202 = r20449199 + r20449201;
        double r20449203 = r20449202 + r20449201;
        double r20449204 = r20449203 + r20449201;
        return r20449204;
}

double f(double x, double y) {
        double r20449205 = x;
        double r20449206 = 3.0;
        double r20449207 = y;
        double r20449208 = r20449206 * r20449207;
        double r20449209 = r20449208 * r20449207;
        double r20449210 = fma(r20449205, r20449205, r20449209);
        return r20449210;
}

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(3, y \cdot y, x \cdot x\right)}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{{x}^{2} + 3 \cdot {y}^{2}}\]
  4. Simplified0.1

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

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

Reproduce

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