Average Error: 0.0 → 0.0
Time: 3.2s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, 2 + x, y \cdot y\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, 2 + x, y \cdot y\right)
double f(double x, double y) {
        double r303004 = x;
        double r303005 = 2.0;
        double r303006 = r303004 * r303005;
        double r303007 = r303004 * r303004;
        double r303008 = r303006 + r303007;
        double r303009 = y;
        double r303010 = r303009 * r303009;
        double r303011 = r303008 + r303010;
        return r303011;
}

double f(double x, double y) {
        double r303012 = x;
        double r303013 = 2.0;
        double r303014 = r303013 + r303012;
        double r303015 = y;
        double r303016 = r303015 * r303015;
        double r303017 = fma(r303012, r303014, r303016);
        return r303017;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[y \cdot y + \left(2 \cdot x + x \cdot x\right)\]

Derivation

  1. Initial program 0.0

    \[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"
  :precision binary64

  :herbie-target
  (+ (* y y) (+ (* 2 x) (* x x)))

  (+ (+ (* x 2) (* x x)) (* y y)))