\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\mathsf{fma}\left(\frac{b}{\sqrt{\mathsf{hypot}\left(c, d\right)}}, \frac{c}{\sqrt{\mathsf{hypot}\left(c, d\right)}}, -\frac{d}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{a}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right) + \frac{d}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \left(\left(-\frac{a}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right) + \frac{a}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right)}{\mathsf{hypot}\left(c, d\right)}double f(double a, double b, double c, double d) {
double r111340 = b;
double r111341 = c;
double r111342 = r111340 * r111341;
double r111343 = a;
double r111344 = d;
double r111345 = r111343 * r111344;
double r111346 = r111342 - r111345;
double r111347 = r111341 * r111341;
double r111348 = r111344 * r111344;
double r111349 = r111347 + r111348;
double r111350 = r111346 / r111349;
return r111350;
}
double f(double a, double b, double c, double d) {
double r111351 = b;
double r111352 = c;
double r111353 = d;
double r111354 = hypot(r111352, r111353);
double r111355 = sqrt(r111354);
double r111356 = r111351 / r111355;
double r111357 = r111352 / r111355;
double r111358 = r111353 / r111355;
double r111359 = a;
double r111360 = r111359 / r111355;
double r111361 = r111358 * r111360;
double r111362 = -r111361;
double r111363 = fma(r111356, r111357, r111362);
double r111364 = -r111360;
double r111365 = r111364 + r111360;
double r111366 = r111358 * r111365;
double r111367 = r111363 + r111366;
double r111368 = r111367 / r111354;
return r111368;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 1.0 |
Initial program 25.9
rmApplied add-sqr-sqrt25.9
Applied *-un-lft-identity25.9
Applied times-frac25.9
Simplified25.9
Simplified17.0
rmApplied *-un-lft-identity17.0
Applied associate-*l*17.0
Simplified16.9
rmApplied div-sub16.9
rmApplied add-sqr-sqrt17.0
Applied times-frac9.4
Applied add-sqr-sqrt9.5
Applied times-frac1.0
Applied prod-diff1.0
Simplified1.0
Final simplification1.0
herbie shell --seed 2020001 +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))))