\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c \cdot b - d \cdot a}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}double f(double a, double b, double c, double d) {
double r3605184 = b;
double r3605185 = c;
double r3605186 = r3605184 * r3605185;
double r3605187 = a;
double r3605188 = d;
double r3605189 = r3605187 * r3605188;
double r3605190 = r3605186 - r3605189;
double r3605191 = r3605185 * r3605185;
double r3605192 = r3605188 * r3605188;
double r3605193 = r3605191 + r3605192;
double r3605194 = r3605190 / r3605193;
return r3605194;
}
double f(double a, double b, double c, double d) {
double r3605195 = c;
double r3605196 = b;
double r3605197 = r3605195 * r3605196;
double r3605198 = d;
double r3605199 = a;
double r3605200 = r3605198 * r3605199;
double r3605201 = r3605197 - r3605200;
double r3605202 = r3605195 * r3605195;
double r3605203 = fma(r3605198, r3605198, r3605202);
double r3605204 = sqrt(r3605203);
double r3605205 = r3605201 / r3605204;
double r3605206 = r3605205 / r3605204;
return r3605206;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.1 |
|---|---|
| Target | 0.5 |
| Herbie | 25.0 |
Initial program 25.1
Simplified25.1
rmApplied add-sqr-sqrt25.1
Applied associate-/r*25.0
rmApplied div-inv25.1
rmApplied associate-*r/25.0
Simplified25.0
Final simplification25.0
herbie shell --seed 2019158 +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))))