Sunday, March 27, 2011

How should complex numbers be rendered?

Mathematics naive question:

What is the "canonical" way to represent 14+1i?

14+i1

or

14+i

Similarly, is it likely, in the 'real world', that scientific notation is going to creep into a complex number so as to freak out a complex numbers parser? For example,

1.2345E+02-1.7002E-09i

Edit: Finally, is it

8.45358210351126e+066i

or

8.45358210351126e+66i

i.e. does one zero file to three digits on the imaginary?

From stackoverflow
  • I would represent your first example as:

    14 + 1i
    

    And I would certainly expect to see scientific notation in complex numbers. For example, Python happily accepts the following (using j as Python requires):

    >>> 1.2345E+02-1.7002E-09j
    (123.45-1.7002e-09j)
    
  • My preference would be:

    14 + i
    

    Somehow it's more pleasing to my eyes than 14 + 1i.

  • "14 + 1i" is better than "14+i1", but I'd be more likely to say or write "14 + i".

    Also, 1.7002E-09i (which I haven't seen in Maths, though no doubt it happens in engineering or something) looks a bit ambiguous without a superscripted font (do you mean 1.7002*(10 ** -9)*i or 1.7002*(10 ** -9*i)?) and therefore (1.7002E-09)i might be better.

  • No problems with MATLAB:

    >> 5+i
    ans =
      5.0000 + 1.0000i
    
    >> 5+1i
    ans =
       5.0000 + 1.0000i
    
    >> 1.2345E+02-1.7002E-09i
    ans =
      1.2345e+002 -1.7002e-009i
    

    I think this shows that scientific notation ("E") in complex numbers is handled pretty well in the "real world"... to the extent that MATLAB is an influential part of that world =)

0 comments:

Post a Comment