\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 r120798 = b;
double r120799 = c;
double r120800 = r120798 * r120799;
double r120801 = a;
double r120802 = d;
double r120803 = r120801 * r120802;
double r120804 = r120800 - r120803;
double r120805 = r120799 * r120799;
double r120806 = r120802 * r120802;
double r120807 = r120805 + r120806;
double r120808 = r120804 / r120807;
return r120808;
}
double f(double a, double b, double c, double d) {
double r120809 = b;
double r120810 = c;
double r120811 = r120810 * r120810;
double r120812 = d;
double r120813 = r120812 * r120812;
double r120814 = r120811 + r120813;
double r120815 = sqrt(r120814);
double r120816 = sqrt(r120815);
double r120817 = r120809 / r120816;
double r120818 = r120810 / r120816;
double r120819 = r120817 * r120818;
double r120820 = a;
double r120821 = r120820 * r120812;
double r120822 = r120821 / r120815;
double r120823 = r120819 - r120822;
double r120824 = r120816 * r120816;
double r120825 = r120823 / r120824;
return r120825;
}




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))))