\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{\mathsf{hypot}\left(d, c\right)}double f(double a, double b, double c, double d) {
double r2025218 = a;
double r2025219 = c;
double r2025220 = r2025218 * r2025219;
double r2025221 = b;
double r2025222 = d;
double r2025223 = r2025221 * r2025222;
double r2025224 = r2025220 + r2025223;
double r2025225 = r2025219 * r2025219;
double r2025226 = r2025222 * r2025222;
double r2025227 = r2025225 + r2025226;
double r2025228 = r2025224 / r2025227;
return r2025228;
}
double f(double a, double b, double c, double d) {
double r2025229 = 1.0;
double r2025230 = d;
double r2025231 = c;
double r2025232 = hypot(r2025230, r2025231);
double r2025233 = r2025229 / r2025232;
double r2025234 = a;
double r2025235 = b;
double r2025236 = r2025235 * r2025230;
double r2025237 = fma(r2025231, r2025234, r2025236);
double r2025238 = r2025237 / r2025232;
double r2025239 = r2025233 * r2025238;
return r2025239;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.6 |
|---|---|
| Target | 0.4 |
| Herbie | 16.1 |
Initial program 25.6
Simplified25.6
rmApplied clear-num25.8
rmApplied *-un-lft-identity25.8
Applied add-sqr-sqrt25.8
Applied times-frac25.8
Applied add-cube-cbrt25.8
Applied times-frac25.7
Simplified25.7
Simplified16.1
Final simplification16.1
herbie shell --seed 2019156 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, real part"
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))