Average Error: 0.0 → 0.0
Time: 1.3s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x, {y}^{2}\right)\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x, {y}^{2}\right)\right)
double f(double x, double y) {
        double r557071 = x;
        double r557072 = 2.0;
        double r557073 = r557071 * r557072;
        double r557074 = r557071 * r557071;
        double r557075 = r557073 + r557074;
        double r557076 = y;
        double r557077 = r557076 * r557076;
        double r557078 = r557075 + r557077;
        return r557078;
}

double f(double x, double y) {
        double r557079 = x;
        double r557080 = 2.0;
        double r557081 = y;
        double r557082 = 2.0;
        double r557083 = pow(r557081, r557082);
        double r557084 = fma(r557080, r557079, r557083);
        double r557085 = fma(r557079, r557079, r557084);
        return r557085;
}

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

    \[\leadsto \color{blue}{{x}^{2} + \left(2 \cdot x + {y}^{2}\right)}\]
  4. Simplified0.0

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

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

Reproduce

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