\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r121342 = b;
double r121343 = c;
double r121344 = r121342 * r121343;
double r121345 = a;
double r121346 = d;
double r121347 = r121345 * r121346;
double r121348 = r121344 - r121347;
double r121349 = r121343 * r121343;
double r121350 = r121346 * r121346;
double r121351 = r121349 + r121350;
double r121352 = r121348 / r121351;
return r121352;
}
double f(double a, double b, double c, double d) {
double r121353 = b;
double r121354 = c;
double r121355 = r121354 * r121354;
double r121356 = d;
double r121357 = r121356 * r121356;
double r121358 = r121355 + r121357;
double r121359 = sqrt(r121358);
double r121360 = r121354 / r121359;
double r121361 = r121353 * r121360;
double r121362 = a;
double r121363 = r121359 / r121356;
double r121364 = r121362 / r121363;
double r121365 = r121361 - r121364;
double r121366 = r121365 / r121359;
return r121366;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 22.1 |
Initial program 25.9
rmApplied add-sqr-sqrt25.9
Applied associate-/r*25.8
rmApplied div-sub25.8
rmApplied associate-/l*24.0
rmApplied *-un-lft-identity24.0
Applied sqrt-prod24.0
Applied times-frac22.1
Simplified22.1
Final simplification22.1
herbie shell --seed 2020001
(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))))