\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}double f(double a, double b, double c, double d) {
double r94646 = b;
double r94647 = c;
double r94648 = r94646 * r94647;
double r94649 = a;
double r94650 = d;
double r94651 = r94649 * r94650;
double r94652 = r94648 - r94651;
double r94653 = r94647 * r94647;
double r94654 = r94650 * r94650;
double r94655 = r94653 + r94654;
double r94656 = r94652 / r94655;
return r94656;
}
double f(double a, double b, double c, double d) {
double r94657 = b;
double r94658 = c;
double r94659 = r94657 * r94658;
double r94660 = a;
double r94661 = d;
double r94662 = r94660 * r94661;
double r94663 = r94659 - r94662;
double r94664 = r94658 * r94658;
double r94665 = r94661 * r94661;
double r94666 = r94664 + r94665;
double r94667 = r94663 / r94666;
return r94667;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 25.9 |
Initial program 25.9
rmApplied add-sqr-sqrt25.9
Applied associate-/r*25.8
rmApplied *-un-lft-identity25.8
Applied sqrt-prod25.8
Applied *-un-lft-identity25.8
Applied sqrt-prod25.8
Applied *-un-lft-identity25.8
Applied times-frac25.8
Applied times-frac25.8
Simplified25.8
Simplified25.9
Final simplification25.9
herbie shell --seed 2020036
(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))))