In real floating point arithmetic we have the additional symbols INF (infinity), NAN and the signed zero. For complex arithmetic this is more difficult. If one uses the "naive" rules for multiplication and division
(a + ib)(c + id) = (ac - db) + i(ac+bd)
(a + ib)/(c + id) = ( (ac + db) + i(ac-bd) ) / (c*c + d*d)
one gets wrong (*) results for almost all cases where where one variable of a,b,c,d is INF or NAN.
For example
- (1 + i0)*(INF + i0) = INF + iNAN . As compared to real arithmetic 1*INF = INF
- (0 + i1)* (NAN + i0) = NAN + iNAN. However one would expect i*NAN = (0+iNAN)
- 1 / (0+0i) = NAN + iNAN. This breaks for example z = 1/(1/z), which works perfectly in real arithmetic.
This list could go on easily.
The question is, how to correctly implement the complex division and multiplication so that all cases, including when one of real or imaginary part is INF and NAN, give meaningful results? Also are there programming languages which guarantee correct behavior for complex arithmetic with INF and NAN?
EDIT: I would like to know which programming language standard (version) does require correct complex arithmetic with INF and NAN. The languages I would be most interested are the C, C++ and FORTRAN families.
(*) wrong in the sense that it is mathematically not meaningful, or is counter-intuitive in the sense of IEEE-754.
<complex>implementation. If you look at theoperator *implementation, it demonstrates how INF/NaN are handled. What do disagree with? - Brett Hale