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 r542527 = x;
        double r542528 = 2.0;
        double r542529 = r542527 * r542528;
        double r542530 = r542527 * r542527;
        double r542531 = r542529 + r542530;
        double r542532 = y;
        double r542533 = r542532 * r542532;
        double r542534 = r542531 + r542533;
        return r542534;
}

double f(double x, double y) {
        double r542535 = x;
        double r542536 = 2.0;
        double r542537 = y;
        double r542538 = 2.0;
        double r542539 = pow(r542537, r542538);
        double r542540 = fma(r542536, r542535, r542539);
        double r542541 = fma(r542535, r542535, r542540);
        return r542541;
}

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