Average Error: 26.4 → 18.2
Time: 6.0s
Precision: binary64
\[\]
\[\]
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)) / ((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) {
	double tmp;
	if ((y_46_im <= -3.6058658773741186e+115) || !(y_46_im <= 2.2524233065491668e+111)) {
		tmp = x_46_im / y_46_im;
	} else {
		tmp = (((x_46_re * y_46_re) + (y_46_im * x_46_im)) * (1.0 / sqrt(pow(y_46_re, 2.0) + pow(y_46_im, 2.0)))) / sqrt((y_46_re * y_46_re) + (y_46_im * y_46_im));
	}
	return tmp;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if y.im < -3.60586587737411862e115 or 2.25242330654916681e111 < y.im

    1. Initial program 41.1

      \[\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt41.1

      \[\leadsto \]
    4. Applied associate-/r*41.1

      \[\leadsto \]
    5. Simplified41.1

      \[\leadsto \]
    6. Taylor expanded around 0 42.6

      \[\leadsto \]
    7. Taylor expanded around 0 16.4

      \[\leadsto \]

    if -3.60586587737411862e115 < y.im < 2.25242330654916681e111

    1. Initial program 19.0

      \[\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt19.1

      \[\leadsto \]
    4. Applied associate-/r*19.0

      \[\leadsto \]
    5. Simplified19.0

      \[\leadsto \]
    6. Using strategy rm
    7. Applied div-inv19.0

      \[\leadsto \]
  3. Recombined 2 regimes into one program.
  4. Final simplification18.2

    \[\leadsto \]

Reproduce

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