\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot b - a \cdot \frac{d}{\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 r3201051 = b;
double r3201052 = c;
double r3201053 = r3201051 * r3201052;
double r3201054 = a;
double r3201055 = d;
double r3201056 = r3201054 * r3201055;
double r3201057 = r3201053 - r3201056;
double r3201058 = r3201052 * r3201052;
double r3201059 = r3201055 * r3201055;
double r3201060 = r3201058 + r3201059;
double r3201061 = r3201057 / r3201060;
return r3201061;
}
double f(double a, double b, double c, double d) {
double r3201062 = c;
double r3201063 = r3201062 * r3201062;
double r3201064 = d;
double r3201065 = r3201064 * r3201064;
double r3201066 = r3201063 + r3201065;
double r3201067 = sqrt(r3201066);
double r3201068 = r3201062 / r3201067;
double r3201069 = b;
double r3201070 = r3201068 * r3201069;
double r3201071 = a;
double r3201072 = r3201064 / r3201067;
double r3201073 = r3201071 * r3201072;
double r3201074 = r3201070 - r3201073;
double r3201075 = r3201074 / r3201067;
return r3201075;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 22.8 |
Initial program 26.1
rmApplied add-sqr-sqrt26.1
Applied associate-/r*26.1
rmApplied div-sub26.1
rmApplied *-un-lft-identity26.1
Applied times-frac24.5
Simplified24.5
rmApplied *-un-lft-identity24.5
Applied sqrt-prod24.5
Applied times-frac22.8
Simplified22.8
Final simplification22.8
herbie shell --seed 2019133
(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))))