\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}double f(double a, double b, double c, double d) {
double r7949635 = b;
double r7949636 = c;
double r7949637 = r7949635 * r7949636;
double r7949638 = a;
double r7949639 = d;
double r7949640 = r7949638 * r7949639;
double r7949641 = r7949637 - r7949640;
double r7949642 = r7949636 * r7949636;
double r7949643 = r7949639 * r7949639;
double r7949644 = r7949642 + r7949643;
double r7949645 = r7949641 / r7949644;
return r7949645;
}
double f(double a, double b, double c, double d) {
double r7949646 = c;
double r7949647 = b;
double r7949648 = r7949646 * r7949647;
double r7949649 = d;
double r7949650 = a;
double r7949651 = r7949649 * r7949650;
double r7949652 = r7949648 - r7949651;
double r7949653 = hypot(r7949646, r7949649);
double r7949654 = r7949652 / r7949653;
double r7949655 = 1.0;
double r7949656 = hypot(r7949649, r7949646);
double r7949657 = r7949655 / r7949656;
double r7949658 = r7949654 * r7949657;
return r7949658;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 16.9 |
Initial program 26.2
Simplified26.2
rmApplied clear-num26.3
rmApplied *-un-lft-identity26.3
Applied add-sqr-sqrt26.3
Applied times-frac26.3
Applied add-cube-cbrt26.3
Applied times-frac26.2
Simplified26.2
Simplified16.9
Final simplification16.9
herbie shell --seed 2019124 +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))))