Average Error: 5.3 → 5.3
Time: 11.4s
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 r369819 = x;
        double r369820 = 1.0;
        double r369821 = y;
        double r369822 = r369821 * r369821;
        double r369823 = r369820 + r369822;
        double r369824 = r369819 * r369823;
        return r369824;
}

double f(double x, double y) {
        double r369825 = y;
        double r369826 = 1.0;
        double r369827 = fma(r369825, r369825, r369826);
        double r369828 = x;
        double r369829 = r369827 * r369828;
        return r369829;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.3

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

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

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

Reproduce

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

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

  (* x (+ 1.0 (* y y))))