\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.92809702332723783 \cdot 10^{94}:\\
\;\;\;\;\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 3.85849841677322835 \cdot 10^{39}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 4.0740961827290516 \cdot 10^{154}:\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{d}}\\
\mathbf{elif}\;c \le 5.21434504503365728 \cdot 10^{171}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r105179 = b;
double r105180 = c;
double r105181 = r105179 * r105180;
double r105182 = a;
double r105183 = d;
double r105184 = r105182 * r105183;
double r105185 = r105181 - r105184;
double r105186 = r105180 * r105180;
double r105187 = r105183 * r105183;
double r105188 = r105186 + r105187;
double r105189 = r105185 / r105188;
return r105189;
}
double f(double a, double b, double c, double d) {
double r105190 = c;
double r105191 = -1.928097023327238e+94;
bool r105192 = r105190 <= r105191;
double r105193 = -1.0;
double r105194 = b;
double r105195 = r105193 * r105194;
double r105196 = d;
double r105197 = hypot(r105190, r105196);
double r105198 = 1.0;
double r105199 = r105197 * r105198;
double r105200 = r105195 / r105199;
double r105201 = 3.8584984167732284e+39;
bool r105202 = r105190 <= r105201;
double r105203 = r105194 * r105190;
double r105204 = a;
double r105205 = r105204 * r105196;
double r105206 = r105203 - r105205;
double r105207 = r105206 / r105197;
double r105208 = r105207 / r105199;
double r105209 = 4.0740961827290516e+154;
bool r105210 = r105190 <= r105209;
double r105211 = r105196 * r105196;
double r105212 = fma(r105190, r105190, r105211);
double r105213 = r105212 / r105190;
double r105214 = r105194 / r105213;
double r105215 = r105212 / r105196;
double r105216 = r105204 / r105215;
double r105217 = r105214 - r105216;
double r105218 = 5.214345045033657e+171;
bool r105219 = r105190 <= r105218;
double r105220 = r105194 / r105199;
double r105221 = r105219 ? r105208 : r105220;
double r105222 = r105210 ? r105217 : r105221;
double r105223 = r105202 ? r105208 : r105222;
double r105224 = r105192 ? r105200 : r105223;
return r105224;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.3 |
|---|---|
| Target | 0.4 |
| Herbie | 13.1 |
if c < -1.928097023327238e+94Initial program 38.9
rmApplied add-sqr-sqrt38.9
Applied *-un-lft-identity38.9
Applied times-frac38.9
Simplified38.9
Simplified27.2
rmApplied associate-*l/27.2
Simplified27.2
Taylor expanded around -inf 17.1
if -1.928097023327238e+94 < c < 3.8584984167732284e+39 or 4.0740961827290516e+154 < c < 5.214345045033657e+171Initial program 19.2
rmApplied add-sqr-sqrt19.2
Applied *-un-lft-identity19.2
Applied times-frac19.3
Simplified19.3
Simplified11.7
rmApplied associate-*l/11.5
Simplified11.5
if 3.8584984167732284e+39 < c < 4.0740961827290516e+154Initial program 22.2
rmApplied div-sub22.2
Simplified14.3
Simplified14.5
if 5.214345045033657e+171 < c Initial program 45.5
rmApplied add-sqr-sqrt45.5
Applied *-un-lft-identity45.5
Applied times-frac45.5
Simplified45.5
Simplified31.4
rmApplied associate-*l/31.4
Simplified31.4
Taylor expanded around inf 13.6
Final simplification13.1
herbie shell --seed 2020083 +o rules:numerics
(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))))