\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}} - d \cdot \frac{a}{c \cdot c + d \cdot d}(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(FPCore (a b c d) :precision binary64 (- (* (/ c (sqrt (+ (* c c) (* d d)))) (/ b (sqrt (+ (* c c) (* d d))))) (* d (/ a (+ (* c c) (* d d))))))
double code(double a, double b, double c, double d) {
return (((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d)))));
}
double code(double a, double b, double c, double d) {
return ((double) (((double) ((c / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))) * (b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))))) - ((double) (d * (a / ((double) (((double) (c * c)) + ((double) (d * d)))))))));
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.6 |
| Herbie | 26.0 |
Initial program Error: 26.5 bits
rmApplied div-subError: 26.5 bits
SimplifiedError: 27.0 bits
SimplifiedError: 27.6 bits
rmApplied add-sqr-sqrtError: 27.6 bits
Applied *-un-lft-identityError: 27.6 bits
Applied times-fracError: 27.6 bits
Applied associate-*r*Error: 26.1 bits
SimplifiedError: 26.0 bits
Final simplificationError: 26.0 bits
herbie shell --seed 2020204
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
: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))))