\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 1.040801148335406884298745436678592487814 \cdot 10^{55}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r5618264 = b;
double r5618265 = c;
double r5618266 = r5618264 * r5618265;
double r5618267 = a;
double r5618268 = d;
double r5618269 = r5618267 * r5618268;
double r5618270 = r5618266 - r5618269;
double r5618271 = r5618265 * r5618265;
double r5618272 = r5618268 * r5618268;
double r5618273 = r5618271 + r5618272;
double r5618274 = r5618270 / r5618273;
return r5618274;
}
double f(double a, double b, double c, double d) {
double r5618275 = d;
double r5618276 = 1.0408011483354069e+55;
bool r5618277 = r5618275 <= r5618276;
double r5618278 = b;
double r5618279 = c;
double r5618280 = r5618278 * r5618279;
double r5618281 = a;
double r5618282 = r5618275 * r5618281;
double r5618283 = r5618280 - r5618282;
double r5618284 = r5618275 * r5618275;
double r5618285 = r5618279 * r5618279;
double r5618286 = r5618284 + r5618285;
double r5618287 = sqrt(r5618286);
double r5618288 = r5618283 / r5618287;
double r5618289 = r5618288 / r5618287;
double r5618290 = -r5618281;
double r5618291 = r5618290 / r5618287;
double r5618292 = r5618277 ? r5618289 : r5618291;
return r5618292;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 26.2 |
if d < 1.0408011483354069e+55Initial program 23.3
rmApplied add-sqr-sqrt23.3
Applied associate-/r*23.3
if 1.0408011483354069e+55 < d Initial program 35.1
rmApplied add-sqr-sqrt35.1
Applied associate-/r*35.1
Taylor expanded around 0 36.3
Simplified36.3
Final simplification26.2
herbie shell --seed 2019192
(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))))