@@ -321,7 +321,7 @@ for division when the right operand is a complex number. Though, if
321321the implementation of floating-point arithmetic supports the IEC 60559
322322floating-point standard, results of all mixed-mode operations, except for
323323division, are specified above unambiguously and it's also expected that
324- multiplication always must be commutative, and that division compute result
324+ multiplication always must be commutative [ 11 ]_ , and that division compute result
325325without undue overflow or underflow.
326326
327327The ``* `` and ``/ `` operators satisfy the following infinity properties for
@@ -627,7 +627,7 @@ Footnotes
627627.. [9] See `N3206: The future of imaginary types
628628 <https:// open-std.org/JTC1/SC22/WG14/www/docs/n3206.htm>`_, WG14. 2023.
629629
630- .. [10] For example, one alternative for the multiplication of complex numbers is
630+ .. [10] Another alternative for the multiplication of complex numbers
631631 (with only three multiplies), see e.g. "Handbook of Floating-Point
632632 Arithmetic" by Muller at al, 2010, Algorithm 4.8:
633633
@@ -643,6 +643,28 @@ Footnotes
643643
644644 Other variants include using a fused multiply-add (FMA) instruction.
645645
646+ .. [11] Its easy to smash this property, as shows the `following algorithm
647+ <https:// www.mjr19.org.uk/IT/IEEE_complex.html>`_:
648+
649+ .. code:: python
650+
651+ def mul3(z, w):
652+ x, y = z.real, z.imag
653+ u, v = w.real, w.imag
654+ t = x*(u + v)
655+ return complex(t - v*(x + y), t + u*(y - x))
656+
657+ Example on IEC 60559-conformant system:
658+
659+ .. code:: pycon
660+
661+ >>> z = 1e308+1.6e308j
662+ >>> w = w=0.1+1j
663+ >>> mul3(z, w)
664+ (-inf+1.1600000000000002e+308j)
665+ >>> mul3(w, z)
666+ (inf+infj)
667+
646668
647669Copyright
648670=========
0 commit comments