\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot \frac{c}{\sqrt{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)}} - \frac{d}{\sqrt{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)}} \cdot a}{\sqrt{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)}}double f(double a, double b, double c, double d) {
double r3839539 = b;
double r3839540 = c;
double r3839541 = r3839539 * r3839540;
double r3839542 = a;
double r3839543 = d;
double r3839544 = r3839542 * r3839543;
double r3839545 = r3839541 - r3839544;
double r3839546 = r3839540 * r3839540;
double r3839547 = r3839543 * r3839543;
double r3839548 = r3839546 + r3839547;
double r3839549 = r3839545 / r3839548;
return r3839549;
}
double f(double a, double b, double c, double d) {
double r3839550 = b;
double r3839551 = c;
double r3839552 = d;
double r3839553 = r3839551 * r3839551;
double r3839554 = fma(r3839552, r3839552, r3839553);
double r3839555 = sqrt(r3839554);
double r3839556 = r3839551 / r3839555;
double r3839557 = r3839550 * r3839556;
double r3839558 = r3839552 / r3839555;
double r3839559 = a;
double r3839560 = r3839558 * r3839559;
double r3839561 = r3839557 - r3839560;
double r3839562 = r3839561 / r3839555;
return r3839562;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 22.8 |
Initial program 26.1
Simplified26.1
rmApplied add-sqr-sqrt26.1
Applied associate-/r*26.1
rmApplied div-sub26.1
rmApplied *-un-lft-identity26.1
Applied sqrt-prod26.1
Applied times-frac24.5
Simplified24.5
rmApplied *-un-lft-identity24.5
Applied sqrt-prod24.5
Applied times-frac22.8
Simplified22.8
Final simplification22.8
herbie shell --seed 2019133 +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))))