\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r13006716 = b;
double r13006717 = c;
double r13006718 = r13006716 * r13006717;
double r13006719 = a;
double r13006720 = d;
double r13006721 = r13006719 * r13006720;
double r13006722 = r13006718 - r13006721;
double r13006723 = r13006717 * r13006717;
double r13006724 = r13006720 * r13006720;
double r13006725 = r13006723 + r13006724;
double r13006726 = r13006722 / r13006725;
return r13006726;
}
double f(double a, double b, double c, double d) {
double r13006727 = b;
double r13006728 = c;
double r13006729 = r13006727 * r13006728;
double r13006730 = a;
double r13006731 = d;
double r13006732 = r13006730 * r13006731;
double r13006733 = r13006729 - r13006732;
double r13006734 = r13006728 * r13006728;
double r13006735 = r13006731 * r13006731;
double r13006736 = r13006734 + r13006735;
double r13006737 = sqrt(r13006736);
double r13006738 = r13006733 / r13006737;
double r13006739 = r13006738 / r13006737;
return r13006739;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.1 |
|---|---|
| Target | 0.5 |
| Herbie | 25.0 |
Initial program 25.1
rmApplied add-sqr-sqrt25.1
Applied associate-/r*25.0
rmApplied div-inv25.1
rmApplied un-div-inv25.0
Final simplification25.0
herbie shell --seed 2019158
(FPCore (a b c d)
:name "Complex division, imag part"
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))