\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;b \le -1.089565161161575170438760363444312591779 \cdot 10^{117}:\\
\;\;\;\;b \cdot \frac{c}{d \cdot d + c \cdot c} - \frac{a \cdot d}{d \cdot d + c \cdot c}\\
\mathbf{elif}\;b \le -1.734488974883629676461830688176453620277 \cdot 10^{-216}:\\
\;\;\;\;\frac{c \cdot b}{d \cdot d + c \cdot c} - \frac{a}{\sqrt{d \cdot d + c \cdot c}} \cdot \frac{d}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{d \cdot d + c \cdot c}{c}} - \frac{a \cdot d}{d \cdot d + c \cdot c}\\
\end{array}double f(double a, double b, double c, double d) {
double r7058628 = b;
double r7058629 = c;
double r7058630 = r7058628 * r7058629;
double r7058631 = a;
double r7058632 = d;
double r7058633 = r7058631 * r7058632;
double r7058634 = r7058630 - r7058633;
double r7058635 = r7058629 * r7058629;
double r7058636 = r7058632 * r7058632;
double r7058637 = r7058635 + r7058636;
double r7058638 = r7058634 / r7058637;
return r7058638;
}
double f(double a, double b, double c, double d) {
double r7058639 = b;
double r7058640 = -1.0895651611615752e+117;
bool r7058641 = r7058639 <= r7058640;
double r7058642 = c;
double r7058643 = d;
double r7058644 = r7058643 * r7058643;
double r7058645 = r7058642 * r7058642;
double r7058646 = r7058644 + r7058645;
double r7058647 = r7058642 / r7058646;
double r7058648 = r7058639 * r7058647;
double r7058649 = a;
double r7058650 = r7058649 * r7058643;
double r7058651 = r7058650 / r7058646;
double r7058652 = r7058648 - r7058651;
double r7058653 = -1.7344889748836297e-216;
bool r7058654 = r7058639 <= r7058653;
double r7058655 = r7058642 * r7058639;
double r7058656 = r7058655 / r7058646;
double r7058657 = sqrt(r7058646);
double r7058658 = r7058649 / r7058657;
double r7058659 = r7058643 / r7058657;
double r7058660 = r7058658 * r7058659;
double r7058661 = r7058656 - r7058660;
double r7058662 = r7058646 / r7058642;
double r7058663 = r7058639 / r7058662;
double r7058664 = r7058663 - r7058651;
double r7058665 = r7058654 ? r7058661 : r7058664;
double r7058666 = r7058641 ? r7058652 : r7058665;
return r7058666;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 24.1 |
if b < -1.0895651611615752e+117Initial program 34.3
rmApplied div-sub34.3
rmApplied *-un-lft-identity34.3
Applied times-frac30.2
Simplified30.2
if -1.0895651611615752e+117 < b < -1.7344889748836297e-216Initial program 23.2
rmApplied div-sub23.2
rmApplied add-sqr-sqrt23.2
Applied times-frac21.6
if -1.7344889748836297e-216 < b Initial program 25.0
rmApplied div-sub25.0
rmApplied associate-/l*23.5
Final simplification24.1
herbie shell --seed 2019200
(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))))