\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 1.0110714407946299 \cdot 10^{85}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r68219 = b;
double r68220 = c;
double r68221 = r68219 * r68220;
double r68222 = a;
double r68223 = d;
double r68224 = r68222 * r68223;
double r68225 = r68221 - r68224;
double r68226 = r68220 * r68220;
double r68227 = r68223 * r68223;
double r68228 = r68226 + r68227;
double r68229 = r68225 / r68228;
return r68229;
}
double f(double a, double b, double c, double d) {
double r68230 = d;
double r68231 = 1.0110714407946299e+85;
bool r68232 = r68230 <= r68231;
double r68233 = b;
double r68234 = c;
double r68235 = r68233 * r68234;
double r68236 = a;
double r68237 = r68236 * r68230;
double r68238 = r68235 - r68237;
double r68239 = r68234 * r68234;
double r68240 = r68230 * r68230;
double r68241 = r68239 + r68240;
double r68242 = sqrt(r68241);
double r68243 = r68238 / r68242;
double r68244 = r68243 / r68242;
double r68245 = -r68236;
double r68246 = r68245 / r68242;
double r68247 = r68232 ? r68244 : r68246;
return r68247;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 25.8 |
if d < 1.0110714407946299e+85Initial program 23.1
rmApplied add-sqr-sqrt23.1
Applied associate-/r*23.1
if 1.0110714407946299e+85 < d Initial program 37.7
rmApplied add-sqr-sqrt37.7
Applied associate-/r*37.6
Taylor expanded around 0 37.1
Simplified37.1
Final simplification25.8
herbie shell --seed 2019195
(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))))