Average Error: 0.1 → 0.1
Time: 21.6s
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(3 \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, y \cdot \left(3 \cdot y\right)\right)
double f(double x, double y) {
        double r262649 = x;
        double r262650 = r262649 * r262649;
        double r262651 = y;
        double r262652 = r262651 * r262651;
        double r262653 = r262650 + r262652;
        double r262654 = r262653 + r262652;
        double r262655 = r262654 + r262652;
        return r262655;
}

double f(double x, double y) {
        double r262656 = x;
        double r262657 = y;
        double r262658 = 3.0;
        double r262659 = r262658 * r262657;
        double r262660 = r262657 * r262659;
        double r262661 = fma(r262656, r262656, r262660);
        return r262661;
}

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 *-un-lft-identity0.1

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(1 \cdot 3\right)} \cdot \left(y \cdot y\right)\right)\]
  5. Applied associate-*l*0.1

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

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

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

Reproduce

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