\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot b - \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 r5397684 = b;
double r5397685 = c;
double r5397686 = r5397684 * r5397685;
double r5397687 = a;
double r5397688 = d;
double r5397689 = r5397687 * r5397688;
double r5397690 = r5397686 - r5397689;
double r5397691 = r5397685 * r5397685;
double r5397692 = r5397688 * r5397688;
double r5397693 = r5397691 + r5397692;
double r5397694 = r5397690 / r5397693;
return r5397694;
}
double f(double a, double b, double c, double d) {
double r5397695 = c;
double r5397696 = r5397695 * r5397695;
double r5397697 = d;
double r5397698 = r5397697 * r5397697;
double r5397699 = r5397696 + r5397698;
double r5397700 = sqrt(r5397699);
double r5397701 = r5397695 / r5397700;
double r5397702 = b;
double r5397703 = r5397701 * r5397702;
double r5397704 = a;
double r5397705 = r5397700 / r5397697;
double r5397706 = r5397704 / r5397705;
double r5397707 = r5397703 - r5397706;
double r5397708 = r5397707 / r5397700;
return r5397708;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.3 |
|---|---|
| Target | 0.5 |
| Herbie | 22.1 |
Initial program 25.3
rmApplied add-sqr-sqrt25.3
Applied associate-/r*25.3
rmApplied div-sub25.3
rmApplied *-un-lft-identity25.3
Applied times-frac23.8
Simplified23.8
rmApplied associate-/l*22.1
Final simplification22.1
herbie shell --seed 2019144
(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))))