\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\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 r78058 = b;
double r78059 = c;
double r78060 = r78058 * r78059;
double r78061 = a;
double r78062 = d;
double r78063 = r78061 * r78062;
double r78064 = r78060 - r78063;
double r78065 = r78059 * r78059;
double r78066 = r78062 * r78062;
double r78067 = r78065 + r78066;
double r78068 = r78064 / r78067;
return r78068;
}
double f(double a, double b, double c, double d) {
double r78069 = b;
double r78070 = c;
double r78071 = r78069 * r78070;
double r78072 = a;
double r78073 = d;
double r78074 = r78072 * r78073;
double r78075 = r78071 - r78074;
double r78076 = 1.0;
double r78077 = r78070 * r78070;
double r78078 = r78073 * r78073;
double r78079 = r78077 + r78078;
double r78080 = sqrt(r78079);
double r78081 = r78076 / r78080;
double r78082 = r78075 * r78081;
double r78083 = r78082 / r78080;
return r78083;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 25.9 |
Initial program 25.9
rmApplied add-sqr-sqrt25.9
Applied associate-/r*25.8
rmApplied div-inv25.9
Final simplification25.9
herbie shell --seed 2019323
(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))))