Average Error: 0.1 → 0.1
Time: 14.9s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y \cdot y, 3, x \cdot x\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(y \cdot y, 3, x \cdot x\right)
double f(double x, double y) {
        double r20852474 = x;
        double r20852475 = r20852474 * r20852474;
        double r20852476 = y;
        double r20852477 = r20852476 * r20852476;
        double r20852478 = r20852475 + r20852477;
        double r20852479 = r20852478 + r20852477;
        double r20852480 = r20852479 + r20852477;
        return r20852480;
}

double f(double x, double y) {
        double r20852481 = y;
        double r20852482 = r20852481 * r20852481;
        double r20852483 = 3.0;
        double r20852484 = x;
        double r20852485 = r20852484 * r20852484;
        double r20852486 = fma(r20852482, r20852483, r20852485);
        return r20852486;
}

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

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

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

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

Reproduce

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