Average Error: 0.0 → 0.0
Time: 12.2s
Precision: 64
\[0 \le x \le 2\]
\[x \cdot \left(x \cdot x\right) + x \cdot x\]
\[\sqrt{\mathsf{fma}\left(x, x \cdot x, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(x, x \cdot x, x \cdot x\right)}\]
x \cdot \left(x \cdot x\right) + x \cdot x
\sqrt{\mathsf{fma}\left(x, x \cdot x, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(x, x \cdot x, x \cdot x\right)}
double f(double x) {
        double r3085929 = x;
        double r3085930 = r3085929 * r3085929;
        double r3085931 = r3085929 * r3085930;
        double r3085932 = r3085931 + r3085930;
        return r3085932;
}

double f(double x) {
        double r3085933 = x;
        double r3085934 = r3085933 * r3085933;
        double r3085935 = fma(r3085933, r3085934, r3085934);
        double r3085936 = sqrt(r3085935);
        double r3085937 = r3085936 * r3085936;
        return r3085937;
}

Error

Bits error versus x

Target

Original0.0
Target0.0
Herbie0.0
\[\left(\left(1.0 + 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. Using strategy rm
  4. Applied add-sqr-sqrt0.0

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

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

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x)
  :name "Expression 3, p15"
  :pre (<= 0 x 2)

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

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