Average Error: 0.1 → 0.1
Time: 3.8s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left({y}^{2}, 3, {x}^{2}\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left({y}^{2}, 3, {x}^{2}\right)
double f(double x, double y) {
        double r532068 = x;
        double r532069 = r532068 * r532068;
        double r532070 = y;
        double r532071 = r532070 * r532070;
        double r532072 = r532069 + r532071;
        double r532073 = r532072 + r532071;
        double r532074 = r532073 + r532071;
        return r532074;
}

double f(double x, double y) {
        double r532075 = y;
        double r532076 = 2.0;
        double r532077 = pow(r532075, r532076);
        double r532078 = 3.0;
        double r532079 = x;
        double r532080 = pow(r532079, r532076);
        double r532081 = fma(r532077, r532078, r532080);
        return r532081;
}

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. Taylor expanded around 0 0.1

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

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

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

Reproduce

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