Average Error: 0.0 → 0.0
Time: 2.4s
Precision: binary64
\[x.re \cdot y.re - x.im \cdot y.im \]
\[\mathsf{fma}\left(x.im, -y.im, x.re \cdot y.re\right) \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (- (* x.re y.re) (* x.im y.im)))
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (fma x.im (- y.im) (* x.re y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return (x_46_re * y_46_re) - (x_46_im * y_46_im);
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return fma(x_46_im, -y_46_im, (x_46_re * y_46_re));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(x_46_re * y_46_re) - Float64(x_46_im * y_46_im))
end
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return fma(x_46_im, Float64(-y_46_im), Float64(x_46_re * y_46_re))
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(x$46$re * y$46$re), $MachinePrecision] - N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im * (-y$46$im) + N[(x$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]
x.re \cdot y.re - x.im \cdot y.im
\mathsf{fma}\left(x.im, -y.im, x.re \cdot y.re\right)

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Initial program 0.0

    \[x.re \cdot y.re - x.im \cdot y.im \]
  2. Taylor expanded in x.re around 0 0.0

    \[\leadsto \color{blue}{x.re \cdot y.re - y.im \cdot x.im} \]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, -y.im, x.re \cdot y.re\right)} \]
  4. Final simplification0.0

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

Reproduce

herbie shell --seed 2022159 
(FPCore (x.re x.im y.re y.im)
  :name "_multiplyComplex, real part"
  :precision binary64
  (- (* x.re y.re) (* x.im y.im)))