Average Error: 0.1 → 0.1
Time: 2.2s
Precision: binary64
\[x \cdot \left(1 - x \cdot y\right) \]
\[x \cdot \left(1 - x \cdot y\right) + x \cdot \mathsf{fma}\left(-y, x, x \cdot y\right) \]
(FPCore (x y) :precision binary64 (* x (- 1.0 (* x y))))
(FPCore (x y)
 :precision binary64
 (+ (* x (- 1.0 (* x y))) (* x (fma (- y) x (* x y)))))
double code(double x, double y) {
	return x * (1.0 - (x * y));
}
double code(double x, double y) {
	return (x * (1.0 - (x * y))) + (x * fma(-y, x, (x * y)));
}
function code(x, y)
	return Float64(x * Float64(1.0 - Float64(x * y)))
end
function code(x, y)
	return Float64(Float64(x * Float64(1.0 - Float64(x * y))) + Float64(x * fma(Float64(-y), x, Float64(x * y))))
end
code[x_, y_] := N[(x * N[(1.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(x * N[(1.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[((-y) * x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \left(1 - x \cdot y\right)
x \cdot \left(1 - x \cdot y\right) + x \cdot \mathsf{fma}\left(-y, x, x \cdot y\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 *-un-lft-identity_binary640.1

    \[\leadsto x \cdot \left(\color{blue}{1 \cdot 1} - x \cdot y\right) \]
  3. Applied prod-diff_binary640.1

    \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(1, 1, -y \cdot x\right) + \mathsf{fma}\left(-y, x, y \cdot x\right)\right)} \]
  4. Applied distribute-rgt-in_binary640.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(1, 1, -y \cdot x\right) \cdot x + \mathsf{fma}\left(-y, x, y \cdot x\right) \cdot x} \]
  5. Applied *-un-lft-identity_binary640.1

    \[\leadsto \mathsf{fma}\left(1, 1, -y \cdot x\right) \cdot \color{blue}{\left(1 \cdot x\right)} + \mathsf{fma}\left(-y, x, y \cdot x\right) \cdot x \]
  6. Applied associate-*r*_binary640.1

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(1, 1, -y \cdot x\right) \cdot 1\right) \cdot x} + \mathsf{fma}\left(-y, x, y \cdot x\right) \cdot x \]
  7. Simplified0.1

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

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

Reproduce

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