\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{c \cdot b - d \cdot a}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r10923654 = b;
double r10923655 = c;
double r10923656 = r10923654 * r10923655;
double r10923657 = a;
double r10923658 = d;
double r10923659 = r10923657 * r10923658;
double r10923660 = r10923656 - r10923659;
double r10923661 = r10923655 * r10923655;
double r10923662 = r10923658 * r10923658;
double r10923663 = r10923661 + r10923662;
double r10923664 = r10923660 / r10923663;
return r10923664;
}
double f(double a, double b, double c, double d) {
double r10923665 = 1.0;
double r10923666 = c;
double r10923667 = r10923666 * r10923666;
double r10923668 = d;
double r10923669 = r10923668 * r10923668;
double r10923670 = r10923667 + r10923669;
double r10923671 = sqrt(r10923670);
double r10923672 = b;
double r10923673 = r10923666 * r10923672;
double r10923674 = a;
double r10923675 = r10923668 * r10923674;
double r10923676 = r10923673 - r10923675;
double r10923677 = r10923671 / r10923676;
double r10923678 = r10923665 / r10923677;
double r10923679 = r10923678 / r10923671;
return r10923679;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.5 |
|---|---|
| Target | 0.4 |
| Herbie | 25.5 |
Initial program 25.5
rmApplied add-sqr-sqrt25.5
Applied associate-/r*25.5
rmApplied *-un-lft-identity25.5
Applied associate-/l*25.5
Final simplification25.5
herbie shell --seed 2019119 +o rules:numerics
(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))))