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

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.1

    \[x \cdot \left(1 - x \cdot y\right) \]
  2. Applied egg-rr8.1

    \[\leadsto \color{blue}{\frac{\left(1 - {\left(x \cdot y\right)}^{2}\right) \cdot x}{1 + x \cdot y}} \]
  3. Applied egg-rr0.2

    \[\leadsto \color{blue}{{\left(\frac{1}{\left(1 - x \cdot y\right) \cdot x}\right)}^{-1}} \]
  4. Taylor expanded in x around 0 7.6

    \[\leadsto \color{blue}{x - y \cdot {x}^{2}} \]
  5. Simplified0.1

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

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

Reproduce

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