Average Error: 0.0 → 0.0
Time: 1.1s
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 r401122 = x;
        double r401123 = 2.0;
        double r401124 = r401122 * r401123;
        double r401125 = r401122 * r401122;
        double r401126 = r401124 + r401125;
        double r401127 = y;
        double r401128 = r401127 * r401127;
        double r401129 = r401126 + r401128;
        return r401129;
}

double f(double x, double y) {
        double r401130 = x;
        double r401131 = 2.0;
        double r401132 = y;
        double r401133 = 2.0;
        double r401134 = pow(r401132, r401133);
        double r401135 = fma(r401131, r401130, r401134);
        double r401136 = fma(r401130, r401130, r401135);
        return r401136;
}

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 2020065 +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)))