Average Error: 0.0 → 0.0
Time: 12.2s
Precision: 64
\[0.0 \le x \le 2\]
\[x \cdot \left(x \cdot x\right) + x \cdot x\]
\[\mathsf{fma}\left(x, x \cdot x, x \cdot x\right)\]
x \cdot \left(x \cdot x\right) + x \cdot x
\mathsf{fma}\left(x, x \cdot x, x \cdot x\right)
double f(double x) {
        double r4516902 = x;
        double r4516903 = r4516902 * r4516902;
        double r4516904 = r4516902 * r4516903;
        double r4516905 = r4516904 + r4516903;
        return r4516905;
}

double f(double x) {
        double r4516906 = x;
        double r4516907 = r4516906 * r4516906;
        double r4516908 = fma(r4516906, r4516907, r4516907);
        return r4516908;
}

Error

Bits error versus x

Target

Original0.0
Target0.0
Herbie0.0
\[\left(\left(1 + x\right) \cdot x\right) \cdot x\]

Derivation

  1. Initial program 0.0

    \[x \cdot \left(x \cdot x\right) + x \cdot x\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(FPCore (x)
  :name "Expression 3, p15"
  :pre (<= 0.0 x 2.0)

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

  (+ (* x (* x x)) (* x x)))