\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}double f(double a, double b, double c, double d) {
double r8532772 = b;
double r8532773 = c;
double r8532774 = r8532772 * r8532773;
double r8532775 = a;
double r8532776 = d;
double r8532777 = r8532775 * r8532776;
double r8532778 = r8532774 - r8532777;
double r8532779 = r8532773 * r8532773;
double r8532780 = r8532776 * r8532776;
double r8532781 = r8532779 + r8532780;
double r8532782 = r8532778 / r8532781;
return r8532782;
}
double f(double a, double b, double c, double d) {
double r8532783 = b;
double r8532784 = c;
double r8532785 = r8532783 * r8532784;
double r8532786 = a;
double r8532787 = d;
double r8532788 = r8532786 * r8532787;
double r8532789 = r8532785 - r8532788;
double r8532790 = cbrt(r8532789);
double r8532791 = r8532790 * r8532790;
double r8532792 = hypot(r8532784, r8532787);
double r8532793 = r8532791 / r8532792;
double r8532794 = r8532792 / r8532790;
double r8532795 = r8532793 / r8532794;
return r8532795;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 17.6 |
Initial program 26.4
Simplified26.4
rmApplied add-sqr-sqrt26.4
Applied associate-/r*26.3
rmApplied *-un-lft-identity26.3
Applied add-cube-cbrt26.8
Applied times-frac26.8
Applied associate-/l*26.9
Simplified23.7
rmApplied associate-/r*17.6
Simplified17.6
Final simplification17.6
herbie shell --seed 2019174 +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))))