Average Error: 0.0 → 0
Time: 720.0ms
Precision: binary64
\[x \cdot \left(1 - x \cdot 0.5\right) \]
\[\mathsf{fma}\left(x, x \cdot -0.5, x\right) \]
(FPCore (x) :precision binary64 (* x (- 1.0 (* x 0.5))))
(FPCore (x) :precision binary64 (fma x (* x -0.5) x))
double code(double x) {
	return x * (1.0 - (x * 0.5));
}
double code(double x) {
	return fma(x, (x * -0.5), x);
}
function code(x)
	return Float64(x * Float64(1.0 - Float64(x * 0.5)))
end
function code(x)
	return fma(x, Float64(x * -0.5), x)
end
code[x_] := N[(x * N[(1.0 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * N[(x * -0.5), $MachinePrecision] + x), $MachinePrecision]
x \cdot \left(1 - x \cdot 0.5\right)
\mathsf{fma}\left(x, x \cdot -0.5, x\right)

Error

Bits error versus x

Derivation

  1. Initial program 0.0

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

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

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

Reproduce

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