\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)}}{b \cdot c - a \cdot d}}}{\sqrt{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)}}double f(double a, double b, double c, double d) {
double r3139969 = b;
double r3139970 = c;
double r3139971 = r3139969 * r3139970;
double r3139972 = a;
double r3139973 = d;
double r3139974 = r3139972 * r3139973;
double r3139975 = r3139971 - r3139974;
double r3139976 = r3139970 * r3139970;
double r3139977 = r3139973 * r3139973;
double r3139978 = r3139976 + r3139977;
double r3139979 = r3139975 / r3139978;
return r3139979;
}
double f(double a, double b, double c, double d) {
double r3139980 = 1.0;
double r3139981 = d;
double r3139982 = c;
double r3139983 = r3139982 * r3139982;
double r3139984 = fma(r3139981, r3139981, r3139983);
double r3139985 = sqrt(r3139984);
double r3139986 = b;
double r3139987 = r3139986 * r3139982;
double r3139988 = a;
double r3139989 = r3139988 * r3139981;
double r3139990 = r3139987 - r3139989;
double r3139991 = r3139985 / r3139990;
double r3139992 = r3139980 / r3139991;
double r3139993 = r3139992 / r3139985;
return r3139993;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.7 |
|---|---|
| Target | 0.5 |
| Herbie | 25.7 |
Initial program 25.7
Simplified25.7
rmApplied add-sqr-sqrt25.7
Applied associate-/r*25.6
rmApplied clear-num25.7
Final simplification25.7
herbie shell --seed 2019130 +o rules:numerics
(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))))