Average Error: 26.1 → 1.5
Time: 16.4s
Precision: binary64
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
\[\mathsf{fma}\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\mathsf{fma}\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (fma
  (/ x.im (hypot y.re y.im))
  (/ y.re (hypot y.re y.im))
  (- (* (/ x.re (hypot y.re y.im)) (/ y.im (hypot y.re y.im))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_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 / hypot(y_46_re, y_46_im)), (y_46_re / hypot(y_46_re, y_46_im)), -((x_46_re / hypot(y_46_re, y_46_im)) * (y_46_im / hypot(y_46_re, y_46_im))));
}

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 26.1

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
  2. Simplified26.1

    \[\leadsto \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}} \]
  3. Applied egg-rr15.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re \cdot y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\right)} \]
  4. Applied egg-rr1.5

    \[\leadsto \mathsf{fma}\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}\right) \]
  5. Final simplification1.5

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

Reproduce

herbie shell --seed 2022130 
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, imaginary part"
  :precision binary64
  (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))