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(bc+ad)
(a + ib)/(c + id) = ( (ac + db) + i(bc-ad) ) / (c*c + d*d)
one gets wrong (*) results for almost all cases where one variable of a,b,c,d is INF or NAN.
For example
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.
For C, please check out Annex G in C99 or C11. At least GCC follows this, I would be surprised if clang didn't.
For C++, IIRC the C++ standard has chosen to not incorporate C99/C11 Annex G, and the algorithms for complex mult/div is up to the implementation.
The Fortran standard does not specify how complex multiplication or division must be implemented. For division, GFortran uses the common Smith (1962) method, except when -ffast-math is specified, then the naive algorithm is used.
For a comparison of different algorithms for computing complex division, please see http://arxiv.org/abs/1210.4539