double f(double a, double b, double c, double d) {
double r19000184 = b;
double r19000185 = c;
double r19000186 = r19000184 * r19000185;
double r19000187 = a;
double r19000188 = d;
double r19000189 = r19000187 * r19000188;
double r19000190 = r19000186 - r19000189;
double r19000191 = r19000185 * r19000185;
double r19000192 = r19000188 * r19000188;
double r19000193 = r19000191 + r19000192;
double r19000194 = r19000190 / r19000193;
return r19000194;
}
double f(double a, double b, double c, double d) {
double r19000195 = b;
double r19000196 = c;
double r19000197 = r19000195 * r19000196;
double r19000198 = r19000196 * r19000196;
double r19000199 = d;
double r19000200 = r19000199 * r19000199;
double r19000201 = r19000198 + r19000200;
double r19000202 = sqrt(r19000201);
double r19000203 = r19000197 / r19000202;
double r19000204 = a;
double r19000205 = r19000199 / r19000202;
double r19000206 = r19000204 * r19000205;
double r19000207 = r19000203 - r19000206;
double r19000208 = r19000207 / r19000202;
return r19000208;
}
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - a \cdot \frac{d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}



Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.5 |
|---|---|
| Target | 0.4 |
| Herbie | 23.9 |
Initial program 25.5
rmApplied add-sqr-sqrt25.5
Applied associate-/r*25.5
Taylor expanded around inf 25.5
rmApplied div-sub25.5
rmApplied *-un-lft-identity25.5
Applied sqrt-prod25.5
Applied times-frac23.9
Simplified23.9
Final simplification23.9
herbie shell --seed 2019102
(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))))