\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r102953 = b;
double r102954 = c;
double r102955 = r102953 * r102954;
double r102956 = a;
double r102957 = d;
double r102958 = r102956 * r102957;
double r102959 = r102955 - r102958;
double r102960 = r102954 * r102954;
double r102961 = r102957 * r102957;
double r102962 = r102960 + r102961;
double r102963 = r102959 / r102962;
return r102963;
}
double f(double a, double b, double c, double d) {
double r102964 = b;
double r102965 = c;
double r102966 = r102964 * r102965;
double r102967 = a;
double r102968 = d;
double r102969 = r102967 * r102968;
double r102970 = r102966 - r102969;
double r102971 = 1.0;
double r102972 = r102965 * r102965;
double r102973 = r102968 * r102968;
double r102974 = r102972 + r102973;
double r102975 = sqrt(r102974);
double r102976 = r102971 / r102975;
double r102977 = r102970 * r102976;
double r102978 = r102977 / r102975;
return r102978;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 26.2 |
Initial program 26.2
rmApplied add-sqr-sqrt26.2
Applied associate-/r*26.1
rmApplied div-inv26.2
Final simplification26.2
herbie shell --seed 2020024
(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))))