\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b}{\frac{\sqrt{c \cdot c + d \cdot d}}{c}} - \frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r131744 = b;
double r131745 = c;
double r131746 = r131744 * r131745;
double r131747 = a;
double r131748 = d;
double r131749 = r131747 * r131748;
double r131750 = r131746 - r131749;
double r131751 = r131745 * r131745;
double r131752 = r131748 * r131748;
double r131753 = r131751 + r131752;
double r131754 = r131750 / r131753;
return r131754;
}
double f(double a, double b, double c, double d) {
double r131755 = b;
double r131756 = c;
double r131757 = r131756 * r131756;
double r131758 = d;
double r131759 = r131758 * r131758;
double r131760 = r131757 + r131759;
double r131761 = sqrt(r131760);
double r131762 = r131761 / r131756;
double r131763 = r131755 / r131762;
double r131764 = a;
double r131765 = r131761 / r131758;
double r131766 = r131764 / r131765;
double r131767 = r131763 - r131766;
double r131768 = r131767 / r131761;
return r131768;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 22.5 |
Initial program 26.1
rmApplied add-sqr-sqrt26.1
Applied associate-/r*26.1
rmApplied add-sqr-sqrt26.1
Applied sqrt-prod26.2
rmApplied div-sub26.2
Simplified24.4
Simplified22.5
Final simplification22.5
herbie shell --seed 2019318
(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))))