\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{c \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}} - d \cdot \frac{a}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{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 (/ b (sqrt (+ (* c c) (* d d))))) (* d (/ a (sqrt (+ (* c c) (* d d)))))) (sqrt (+ (* 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 * (b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))))) - ((double) (d * (a / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))))))) / ((double) sqrt(((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.0 |
|---|---|
| Target | 0.4 |
| Herbie | 22.8 |
Initial program Error: 26.0 bits
rmApplied add-sqr-sqrtError: 26.0 bits
Applied associate-/r*Error: 25.9 bits
rmApplied div-subError: 25.9 bits
SimplifiedError: 24.2 bits
SimplifiedError: 22.8 bits
Final simplificationError: 22.8 bits
herbie shell --seed 2020203
(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))))