Average Error: 5.2 → 5.2
Time: 11.7s
Precision: 64
\[x \cdot \left(1 + y \cdot y\right)\]
\[\mathsf{fma}\left(y, y, 1\right) \cdot x\]
x \cdot \left(1 + y \cdot y\right)
\mathsf{fma}\left(y, y, 1\right) \cdot x
double f(double x, double y) {
        double r392489 = x;
        double r392490 = 1.0;
        double r392491 = y;
        double r392492 = r392491 * r392491;
        double r392493 = r392490 + r392492;
        double r392494 = r392489 * r392493;
        return r392494;
}

double f(double x, double y) {
        double r392495 = y;
        double r392496 = 1.0;
        double r392497 = fma(r392495, r392495, r392496);
        double r392498 = x;
        double r392499 = r392497 * r392498;
        return r392499;
}

Error

Bits error versus x

Bits error versus y

Target

Original5.2
Target0.1
Herbie5.2
\[x + \left(x \cdot y\right) \cdot y\]

Derivation

  1. Initial program 5.2

    \[x \cdot \left(1 + y \cdot y\right)\]
  2. Simplified5.2

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

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

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
  :precision binary64

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

  (* x (+ 1 (* y y))))