\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b}{\frac{d}{\frac{c}{d}} + c} - \frac{a}{\frac{c}{\frac{d}{c}} + d}double f(double a, double b, double c, double d) {
double r94207 = b;
double r94208 = c;
double r94209 = r94207 * r94208;
double r94210 = a;
double r94211 = d;
double r94212 = r94210 * r94211;
double r94213 = r94209 - r94212;
double r94214 = r94208 * r94208;
double r94215 = r94211 * r94211;
double r94216 = r94214 + r94215;
double r94217 = r94213 / r94216;
return r94217;
}
double f(double a, double b, double c, double d) {
double r94218 = b;
double r94219 = d;
double r94220 = c;
double r94221 = r94220 / r94219;
double r94222 = r94219 / r94221;
double r94223 = r94222 + r94220;
double r94224 = r94218 / r94223;
double r94225 = a;
double r94226 = r94219 / r94220;
double r94227 = r94220 / r94226;
double r94228 = r94227 + r94219;
double r94229 = r94225 / r94228;
double r94230 = r94224 - r94229;
return r94230;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.6 |
|---|---|
| Target | 0.4 |
| Herbie | 3.3 |
Initial program 25.6
rmApplied div-sub25.6
Simplified24.1
Taylor expanded around 0 17.2
Simplified17.2
rmApplied *-un-lft-identity17.2
Applied *-un-lft-identity17.2
Applied distribute-lft-out--17.2
Simplified13.8
Taylor expanded around 0 5.3
Simplified3.3
Final simplification3.3
herbie shell --seed 2019194
(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))))