Skip to content
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fa9c087
Initial version
skirpichev Dec 5, 2023
fea0b1d
Reserve number 812
skirpichev Oct 29, 2025
5665f85
+ format refs
skirpichev Oct 31, 2025
983e5da
+ set Sponsor & .github/CODEOWNERS
skirpichev Oct 31, 2025
d7d6f0e
cleanup: use extlinks
skirpichev Nov 1, 2025
ad7d448
+ imaginary literals and marshal
skirpichev Nov 1, 2025
369a213
+ NO latex
skirpichev Nov 1, 2025
f4c9c9c
link to Kahan paper
skirpichev Nov 1, 2025
a5bb13a
ad7d448f +1
skirpichev Nov 1, 2025
bc825bf
+ mention mpmath issue 473
skirpichev Nov 1, 2025
63140c2
Merge branch 'master' into imaginary
skirpichev Nov 2, 2025
f69e6c5
Merge branch 'master' into imaginary
skirpichev Nov 4, 2025
27a429f
Merge branch 'master' into imaginary
skirpichev Nov 5, 2025
29fef03
Apply suggestions from code review
skirpichev Nov 5, 2025
0df61c9
Merge branch 'imaginary' of github.com:skirpichev/peps into imaginary
skirpichev Nov 5, 2025
612f2af
address review: apply rest of suggestions
skirpichev Nov 5, 2025
a31d7c1
+ add another algorithm for multiplication
skirpichev Nov 6, 2025
e961ef7
fix formatting
skirpichev Nov 6, 2025
5f35d52
Update peps/pep-0812.rst
skirpichev Nov 7, 2025
b573c82
Merge branch 'main' into imaginary
skirpichev Nov 16, 2025
bf0d67f
address review: move inline footnotes 5-7
skirpichev Nov 16, 2025
27b45b9
+ expose imaginary builtin
skirpichev Nov 20, 2025
8fe6c41
+ ast
skirpichev Nov 20, 2025
e8c8803
separate section for arithmetic
skirpichev Nov 21, 2025
7353470
+ specify more properties for * and /
skirpichev Nov 21, 2025
8e12d53
footnote on complex infinity
skirpichev Nov 21, 2025
036d49c
Merge branch 'main' into imaginary
skirpichev Dec 12, 2025
ffbc299
Merge branch 'master' into imaginary
skirpichev Dec 19, 2025
252c83d
Simplify imaginary() constructor
skirpichev Dec 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
+ add another algorithm for multiplication
  • Loading branch information
skirpichev committed Nov 6, 2025
commit a31d7c134de756ccbf652b0b153e1be57d8f795e
26 changes: 24 additions & 2 deletions peps/pep-0812.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ for division when the right operand is a complex number. Though, if
the implementation of floating-point arithmetic supports the IEC 60559
floating-point standard, results of all mixed-mode operations, except for
division, are specified above unambiguously and it's also expected that
multiplication always must be commutative, and that division compute result
multiplication always must be commutative [11]_, and that division compute result
without undue overflow or underflow.

The ``*`` and ``/`` operators satisfy the following infinity properties for
Expand Down Expand Up @@ -627,7 +627,7 @@ Footnotes
.. [9] See `N3206: The future of imaginary types
<https://open-std.org/JTC1/SC22/WG14/www/docs/n3206.htm>`_, WG14. 2023.

.. [10] For example, one alternative for the multiplication of complex numbers is
.. [10] Another alternative for the multiplication of complex numbers
(with only three multiplies), see e.g. "Handbook of Floating-Point
Arithmetic" by Muller at al, 2010, Algorithm 4.8:

Expand All @@ -643,6 +643,28 @@ Footnotes

Other variants include using a fused multiply-add (FMA) instruction.

.. [11] Its easy to smash this property, as shows the `following algorithm
<https://www.mjr19.org.uk/IT/IEEE_complex.html>`_:

.. code:: python

def mul3(z, w):
x, y = z.real, z.imag
u, v = w.real, w.imag
t = x*(u + v)
return complex(t - v*(x + y), t + u*(y - x))

Example on IEC 60559-conformant system:

.. code:: pycon

>>> z = 1e308+1.6e308j
>>> w = 0.1+1j
>>> mul3(z, w)
(-inf+1.1600000000000002e+308j)
>>> mul3(w, z)
(inf+infj)


Copyright
=========
Expand Down