Average Error: 0.0 → 0
Time: 968.0ms
Precision: binary64
\[x \cdot \left(1 - x \cdot 0.5\right) \]
\[\mathsf{fma}\left(x \cdot -0.5, x, x\right) \]
x \cdot \left(1 - x \cdot 0.5\right)
\mathsf{fma}\left(x \cdot -0.5, x, x\right)
(FPCore (x) :precision binary64 (* x (- 1.0 (* x 0.5))))
(FPCore (x) :precision binary64 (fma (* x -0.5) x x))
double code(double x) {
	return x * (1.0 - (x * 0.5));
}
double code(double x) {
	return fma((x * -0.5), x, x);
}

Error

Bits error versus x

Derivation

  1. Initial program 0.0

    \[x \cdot \left(1 - x \cdot 0.5\right) \]
  2. Simplified0.0

    \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x, -0.5, 1\right)} \]
  3. Using strategy rm
  4. Applied fma-udef_binary640.0

    \[\leadsto x \cdot \color{blue}{\left(x \cdot -0.5 + 1\right)} \]
  5. Applied distribute-rgt-in_binary640.0

    \[\leadsto \color{blue}{\left(x \cdot -0.5\right) \cdot x + 1 \cdot x} \]
  6. Applied fma-def_binary640

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot -0.5, x, 1 \cdot x\right)} \]
  7. Final simplification0

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

Reproduce

herbie shell --seed 2021211 
(FPCore (x)
  :name "Numeric.SpecFunctions:log1p from math-functions-0.1.5.2, B"
  :precision binary64
  (* x (- 1.0 (* x 0.5))))