\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot \left(b \cdot c - a \cdot d\right)}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}double f(double a, double b, double c, double d) {
double r4810638 = b;
double r4810639 = c;
double r4810640 = r4810638 * r4810639;
double r4810641 = a;
double r4810642 = d;
double r4810643 = r4810641 * r4810642;
double r4810644 = r4810640 - r4810643;
double r4810645 = r4810639 * r4810639;
double r4810646 = r4810642 * r4810642;
double r4810647 = r4810645 + r4810646;
double r4810648 = r4810644 / r4810647;
return r4810648;
}
double f(double a, double b, double c, double d) {
double r4810649 = 1.0;
double r4810650 = d;
double r4810651 = c;
double r4810652 = r4810651 * r4810651;
double r4810653 = fma(r4810650, r4810650, r4810652);
double r4810654 = sqrt(r4810653);
double r4810655 = r4810649 / r4810654;
double r4810656 = b;
double r4810657 = r4810656 * r4810651;
double r4810658 = a;
double r4810659 = r4810658 * r4810650;
double r4810660 = r4810657 - r4810659;
double r4810661 = r4810655 * r4810660;
double r4810662 = r4810661 / r4810654;
return r4810662;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.1 |
|---|---|
| Target | 0.5 |
| Herbie | 25.1 |
Initial program 25.1
Simplified25.1
rmApplied add-sqr-sqrt25.1
Applied associate-/r*25.0
rmApplied div-inv25.1
Final simplification25.1
herbie shell --seed 2019164 +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))))