\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b}{\sqrt{\sqrt{c \cdot c + d \cdot d}}} \cdot \frac{c}{\sqrt{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{\sqrt{c \cdot c + d \cdot d}} \cdot \sqrt{\sqrt{c \cdot c + d \cdot d}}}double f(double a, double b, double c, double d) {
double r120768 = b;
double r120769 = c;
double r120770 = r120768 * r120769;
double r120771 = a;
double r120772 = d;
double r120773 = r120771 * r120772;
double r120774 = r120770 - r120773;
double r120775 = r120769 * r120769;
double r120776 = r120772 * r120772;
double r120777 = r120775 + r120776;
double r120778 = r120774 / r120777;
return r120778;
}
double f(double a, double b, double c, double d) {
double r120779 = b;
double r120780 = c;
double r120781 = r120780 * r120780;
double r120782 = d;
double r120783 = r120782 * r120782;
double r120784 = r120781 + r120783;
double r120785 = sqrt(r120784);
double r120786 = sqrt(r120785);
double r120787 = r120779 / r120786;
double r120788 = r120780 / r120786;
double r120789 = r120787 * r120788;
double r120790 = a;
double r120791 = r120790 * r120782;
double r120792 = r120791 / r120785;
double r120793 = r120789 - r120792;
double r120794 = r120786 * r120786;
double r120795 = r120793 / r120794;
return r120795;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 24.3 |
Initial program 25.8
rmApplied add-sqr-sqrt25.8
Applied associate-/r*25.7
rmApplied div-sub25.7
rmApplied add-sqr-sqrt25.7
Applied sqrt-prod25.8
Applied times-frac24.1
rmApplied add-sqr-sqrt24.1
Applied sqrt-prod24.3
Final simplification24.3
herbie shell --seed 2019303
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
: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))))