In your computation you are assuming that multiplication with floating point numbers always obeys the associative law of multiplication exactly, but that is not necessarily true. Rounding after each operation can cause small differences in results. Try putting parentheses in your product
( test(1)*test(2)*test(3) ) * ( test(4)*test(5)*test(6) )
and notice the difference.
The point is that because of rounding differences, multiplying a sequence of three or more factors can yield different results if the factors are grouped differently. If you use a variety of different real numbers for test(4), the result of
will sometimes have a non-zero imaginary component. That is because this product is ordinarily performed as though it had parentheses like this
( test(4)*test(5) ) * test(6)
and in the second multiplication you are no longer multiplying complex conjugate numbers, though in theory their product should be real. Rounding differences can lead to a non-zero imaginary part.
Best Answer