Average Error: 5.4 → 5.4
Time: 12.3s
Precision: 64
\[x \cdot \left(1 + y \cdot y\right)\]
\[\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot x\right)\]
x \cdot \left(1 + y \cdot y\right)
\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot x\right)
double f(double x, double y) {
        double r358856 = x;
        double r358857 = 1.0;
        double r358858 = y;
        double r358859 = r358858 * r358858;
        double r358860 = r358857 + r358859;
        double r358861 = r358856 * r358860;
        return r358861;
}

double f(double x, double y) {
        double r358862 = y;
        double r358863 = 1.0;
        double r358864 = fma(r358862, r358862, r358863);
        double r358865 = sqrt(r358864);
        double r358866 = x;
        double r358867 = r358865 * r358866;
        double r358868 = r358865 * r358867;
        return r358868;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 5.4

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, 1\right) \cdot x}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt5.4

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)} \cdot x\]
  5. Applied associate-*l*5.4

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

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

Reproduce

herbie shell --seed 2019196 +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))))