\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(d, c\right)}double f(double a, double b, double c, double d) {
double r3324128 = b;
double r3324129 = c;
double r3324130 = r3324128 * r3324129;
double r3324131 = a;
double r3324132 = d;
double r3324133 = r3324131 * r3324132;
double r3324134 = r3324130 - r3324133;
double r3324135 = r3324129 * r3324129;
double r3324136 = r3324132 * r3324132;
double r3324137 = r3324135 + r3324136;
double r3324138 = r3324134 / r3324137;
return r3324138;
}
double f(double a, double b, double c, double d) {
double r3324139 = 1.0;
double r3324140 = d;
double r3324141 = c;
double r3324142 = hypot(r3324140, r3324141);
double r3324143 = r3324139 / r3324142;
double r3324144 = b;
double r3324145 = r3324141 * r3324144;
double r3324146 = a;
double r3324147 = r3324140 * r3324146;
double r3324148 = r3324145 - r3324147;
double r3324149 = r3324148 / r3324142;
double r3324150 = r3324143 * r3324149;
return r3324150;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.2 |
|---|---|
| Target | 0.5 |
| Herbie | 16.1 |
Initial program 25.2
Simplified25.2
rmApplied clear-num25.3
rmApplied *-un-lft-identity25.3
Applied add-sqr-sqrt25.3
Applied times-frac25.3
Applied add-cube-cbrt25.3
Applied times-frac25.2
Simplified25.2
Simplified16.1
Final simplification16.1
herbie shell --seed 2019129 +o rules:numerics
(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))))