\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}double f(double a, double b, double c, double d) {
double r100926 = b;
double r100927 = c;
double r100928 = r100926 * r100927;
double r100929 = a;
double r100930 = d;
double r100931 = r100929 * r100930;
double r100932 = r100928 - r100931;
double r100933 = r100927 * r100927;
double r100934 = r100930 * r100930;
double r100935 = r100933 + r100934;
double r100936 = r100932 / r100935;
return r100936;
}
double f(double a, double b, double c, double d) {
double r100937 = c;
double r100938 = d;
double r100939 = hypot(r100937, r100938);
double r100940 = r100937 / r100939;
double r100941 = b;
double r100942 = r100940 * r100941;
double r100943 = a;
double r100944 = r100943 / r100939;
double r100945 = r100938 * r100944;
double r100946 = r100942 - r100945;
double r100947 = r100946 / r100939;
return r100947;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.9 |
Initial program 26.2
Simplified26.2
rmApplied add-sqr-sqrt26.2
Applied *-un-lft-identity26.2
Applied times-frac26.2
Simplified26.2
Simplified17.0
rmApplied *-un-lft-identity17.0
Applied associate-*l*17.0
Simplified16.9
rmApplied div-sub16.9
Simplified9.9
Simplified1.3
rmApplied associate-/r/0.9
Final simplification0.9
herbie shell --seed 2019325 +o rules:numerics
(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))))