\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot c - d \cdot a}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot \frac{1}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}double f(double a, double b, double c, double d) {
double r1752172 = b;
double r1752173 = c;
double r1752174 = r1752172 * r1752173;
double r1752175 = a;
double r1752176 = d;
double r1752177 = r1752175 * r1752176;
double r1752178 = r1752174 - r1752177;
double r1752179 = r1752173 * r1752173;
double r1752180 = r1752176 * r1752176;
double r1752181 = r1752179 + r1752180;
double r1752182 = r1752178 / r1752181;
return r1752182;
}
double f(double a, double b, double c, double d) {
double r1752183 = b;
double r1752184 = c;
double r1752185 = r1752183 * r1752184;
double r1752186 = d;
double r1752187 = a;
double r1752188 = r1752186 * r1752187;
double r1752189 = r1752185 - r1752188;
double r1752190 = r1752184 * r1752184;
double r1752191 = fma(r1752186, r1752186, r1752190);
double r1752192 = sqrt(r1752191);
double r1752193 = r1752189 / r1752192;
double r1752194 = 1.0;
double r1752195 = r1752194 / r1752192;
double r1752196 = r1752193 * r1752195;
return r1752196;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.8 |
|---|---|
| Target | 0.5 |
| Herbie | 25.8 |
Initial program 25.8
Simplified25.8
rmApplied add-sqr-sqrt25.8
Applied *-un-lft-identity25.8
Applied times-frac25.8
Final simplification25.8
herbie shell --seed 2019155 +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))))