\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -1.351214721549483218261281106569258966909 \cdot 10^{154} \lor \neg \left(d \le 8.000358861136643239312158095843514305232 \cdot 10^{153}\right):\\
\;\;\;\;\frac{b}{\frac{c \cdot c + d \cdot d}{c}} - \frac{a}{d + \frac{{c}^{2}}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c} + c} - \frac{a}{\frac{c \cdot c + d \cdot d}{d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r140301 = b;
double r140302 = c;
double r140303 = r140301 * r140302;
double r140304 = a;
double r140305 = d;
double r140306 = r140304 * r140305;
double r140307 = r140303 - r140306;
double r140308 = r140302 * r140302;
double r140309 = r140305 * r140305;
double r140310 = r140308 + r140309;
double r140311 = r140307 / r140310;
return r140311;
}
double f(double a, double b, double c, double d) {
double r140312 = d;
double r140313 = -1.3512147215494832e+154;
bool r140314 = r140312 <= r140313;
double r140315 = 8.000358861136643e+153;
bool r140316 = r140312 <= r140315;
double r140317 = !r140316;
bool r140318 = r140314 || r140317;
double r140319 = b;
double r140320 = c;
double r140321 = r140320 * r140320;
double r140322 = r140312 * r140312;
double r140323 = r140321 + r140322;
double r140324 = r140323 / r140320;
double r140325 = r140319 / r140324;
double r140326 = a;
double r140327 = 2.0;
double r140328 = pow(r140320, r140327);
double r140329 = r140328 / r140312;
double r140330 = r140312 + r140329;
double r140331 = r140326 / r140330;
double r140332 = r140325 - r140331;
double r140333 = pow(r140312, r140327);
double r140334 = r140333 / r140320;
double r140335 = r140334 + r140320;
double r140336 = r140319 / r140335;
double r140337 = r140323 / r140312;
double r140338 = r140326 / r140337;
double r140339 = r140336 - r140338;
double r140340 = r140318 ? r140332 : r140339;
return r140340;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 8.6 |
if d < -1.3512147215494832e+154 or 8.000358861136643e+153 < d Initial program 46.6
rmApplied add-sqr-sqrt46.6
rmApplied div-sub46.6
Simplified46.4
Simplified45.3
Taylor expanded around 0 16.8
if -1.3512147215494832e+154 < d < 8.000358861136643e+153Initial program 18.8
rmApplied add-sqr-sqrt18.8
rmApplied div-sub18.8
Simplified17.0
Simplified15.2
Taylor expanded around 0 5.4
Final simplification8.6
herbie shell --seed 2019353
(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))))