Average Error: 0.0 → 0.0
Time: 948.0ms
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 r470782 = x;
        double r470783 = 2.0;
        double r470784 = r470782 * r470783;
        double r470785 = r470782 * r470782;
        double r470786 = r470784 + r470785;
        double r470787 = y;
        double r470788 = r470787 * r470787;
        double r470789 = r470786 + r470788;
        return r470789;
}

double f(double x, double y) {
        double r470790 = x;
        double r470791 = 2.0;
        double r470792 = y;
        double r470793 = 2.0;
        double r470794 = pow(r470792, r470793);
        double r470795 = fma(r470791, r470790, r470794);
        double r470796 = fma(r470790, r470790, r470795);
        return r470796;
}

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