Average Error: 0.1 → 0.1
Time: 24.0s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, 3 \cdot \left(y \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, 3 \cdot \left(y \cdot y\right)\right)
double f(double x, double y) {
        double r296772 = x;
        double r296773 = r296772 * r296772;
        double r296774 = y;
        double r296775 = r296774 * r296774;
        double r296776 = r296773 + r296775;
        double r296777 = r296776 + r296775;
        double r296778 = r296777 + r296775;
        return r296778;
}

double f(double x, double y) {
        double r296779 = x;
        double r296780 = 3.0;
        double r296781 = y;
        double r296782 = r296781 * r296781;
        double r296783 = r296780 * r296782;
        double r296784 = fma(r296779, r296779, r296783);
        return r296784;
}

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. Final simplification0.1

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

Reproduce

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