Complex literals (was Re: I am never going to complain about Pythonagain)

C

Chris Angelico

BTW, one of the earliest things that turned me on to Python was when I
discovered that it uses j as the imaginary unit, not i. All
right-thinking people will agree with me on this.

I've never been well-up on complex numbers; can you elaborate on this,
please? All I know is that I was taught that the square root of -1 is
called i, and that hypercomplex numbers include i, j, k, and maybe
even other terms, and I never understood where j comes from. Why is
Python better for using j?

ChrisA
 
G

Grant Edwards

I've never been well-up on complex numbers; can you elaborate on this,
please? All I know is that I was taught that the square root of -1 is
called i,

Nope. "i" is electical current (though it's more customary to use
upper case). "j" is the square root of -1.
and that hypercomplex numbers include i, j, k, and maybe even other
terms, and I never understood where j comes from. Why is Python
better for using j?

Because that's the way we do it in electrical engineering.

;)
 
C

Chris Angelico

Nope. "i" is electical current (though it's more customary to use
upper case). "j" is the square root of -1.


Because that's the way we do it in electrical engineering.

Okay, so hold on a minute... a hypercomplex number is the sum of a
real number, some electrical current, an imaginary number, and k?

This belongs in the Izzet League, I think.

ChrisA
 
G

Grant Edwards

Okay, so hold on a minute... a hypercomplex number is the sum of a
real number, some electrical current, an imaginary number, and k?

I don't know that EE's ever encounter hypercomplex numbers (I
certainly never have), nor does Python support them, so in _practice_
there isn't really a conflict.
 
E

Ethan Furman

Okay, so hold on a minute... a hypercomplex number is the sum of a
real number, some electrical current, an imaginary number, and k?

That would certainly explain why it's hyper. ;)
 
S

Steven D'Aprano

I've never been well-up on complex numbers; can you elaborate on this,
please? All I know is that I was taught that the square root of -1 is
called i, and that hypercomplex numbers include i, j, k, and maybe even
other terms, and I never understood where j comes from. Why is Python
better for using j?

Being simple souls and not Real Mathematicians, electrical engineers get
confused by the similarity between I (current) and i (square root of -1),
so they used j instead. Real Mathematicians are hardy folk completely at
home with such ambiguity -- if you can deal with superscript -1 meaning
both "inverse function" and "reciprocal" *in the same equation*, i vs I
hold no fears for you.

<wink>

But seriously... I think the convention to use j for complex numbers
comes from the convention of using i, j, k as unit vectors, i being in
the X direction (corresponding to the real axis), j being in the Y
direction (corresponding to the imaginary axis), and k being in the Z
direction.

For what it's worth, there is no three-dimensional extension to complex
numbers, but there is a four-dimensional one, the quaternions or
hypercomplex numbers. They look like 1 + 2i + 3j + 4k, where i, j and k
are all distinct but i**2 == j**2 == k**2 == -1. Quaternions had a brief
period of popularity during the late 19th century but fell out of
popularity in the 20th. In recent years, they're making something of a
comeback, as using quaternions for calculating rotations is more
numerically stable than traditional matrix calculations.

Unlike reals and complex numbers, quaternions are non-commutative: in
general, q1*q2 != q2*q1.

There are also octonions, eight-dimensional numbers which are non-
commutative and non-associative, (o1*o2)*o3 != o1*(o2*o3), and sedenions,
a 16-dimensional number.
 
C

Chris Angelico

Was that an MtG reference?

It most assuredly was. The Ravnican guild known as the Izzet League
(epitomizing the color combination Red-Blue, mixing passion and chaos
with artifice and control) works a lot with electricity, madness,
science, and mad electrical science... it seemed a fair similarity.

ChrisA
 
D

David

I've never been well-up on complex numbers; can you elaborate on this,
please? All I know is that I was taught that the square root of -1 is
called i, and that hypercomplex numbers include i, j, k, and maybe even
other terms, and I never understood where j comes from. Why is Python
better for using j?

Being simple souls and not Real Mathematicians, electrical engineers get
confused by the similarity between I (current) and i (square root of -1),
so they used j instead. [...]
<wink>

No, electrical engineers need many symbols for current for the same reason
that eskimos need many words for snow :) [*]

[*] https://en.wikipedia.org/wiki/Eskimo_words_for_snow
 
O

Oscar Benjamin

BTW, one of the earliest things that turned me on to Python was when I
discovered that it uses j as the imaginary unit, not i. All
right-thinking people will agree with me on this.

I've never been well-up on complex numbers; can you elaborate on this,
please? All I know is that I was taught that the square root of -1 is
called i, and that hypercomplex numbers include i, j, k, and maybe even
other terms, and I never understood where j comes from. Why is Python
better for using j?

Being simple souls and not Real Mathematicians, electrical engineers get
confused by the similarity between I (current) and i (square root of -1),
so they used j instead. [...]
<wink>

No, electrical engineers need many symbols for current for the same reason
that eskimos need many words for snow :) [*]

There are many other letters in the Roman alphabet to choose from
though. In particular the study of complex numbers and the choice of i
for sqrt(-1) predates most of the study of electricity and the use of
I to denote current (it was previously called C in English texts).
Obviously I understand that that's all history and once conventions
are so widely adopted it's pointless to change them but it's good to
have common notation for the elementary parts of maths. If someone
tried to explain why their field couldn't use ð for the circumference
of a unit circle I would suggest that they adjust the other parts of
their notation not ð (there are other uses of ð.

Truthfully I've now spent more time with engineers than
physicists/mathematicians and find it natural to switch between i and
j depending on who I'm talking to and what I'm talking about. It's
still confusing for students though when I switch between conventions
to use whichever is standard for a given subject.


Oscar
 
J

Jussi Piitulainen

Oscar said:
tried to explain why their field couldn't use π for the
circumference of a unit circle I would suggest that they adjust the
other parts of their notation not π (there are other uses of π.

There's τ for the full circle; π is used for half the circumference.

<duck/>
 
R

Roy Smith

Oscar Benjamin said:
If someone tried to explain why their field couldn't use ð for the
circumference of a unit circle I would suggest that they adjust the
other parts of their notation not ð (there are other uses of ð.

Pi is wrong:

 
G

Gene Heskett

Pi is wrong:


The funnily/serious part of this current "comedy central session" is that,
speaking as someone who was too busy fixing tv's for a living in the 1950
era, to go far enough in school to get any really higher math, (algebra
enough to solve ohms law etc was all I usually needed) the above argument
has always made perfect sense to me, and I have often arrived at the
correct answer to some problem by using 2Pi, but usually without calling it
Tau. And even that wasn't needed often enough to keep my mind fresh about
it. But I managed to get the job done anyway, those two tv cameras that
were on the Trieste when it went into the Challenger Deep in 1960 had
traces of my fingerprints in them.

Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

Linux poses a real challenge for those with a taste for late-night
hacking (and/or conversations with God).
-- Matt Welsh
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.
 
S

Steven D'Aprano

Pi is wrong:

Pi is right, your newsreader is wrong. Oscar's post included the header:

Content-Type: text/plain; charset=ISO-8859-7

Your newsreader ignores the charset header and just assumes it is
Latin-1. Since pi (Ï€) in ISO-8859-7 is byte \xF0, your newsreader wrongly
treats it as ð (LATIN SMALL LETTER ETH).
 
J

John Nagle

For what it's worth, there is no three-dimensional extension to complex
numbers, but there is a four-dimensional one, the quaternions or
hypercomplex numbers. They look like 1 + 2i + 3j + 4k, where i, j and k
are all distinct but i**2 == j**2 == k**2 == -1. Quaternions had a brief
period of popularity during the late 19th century but fell out of
popularity in the 20th. In recent years, they're making something of a
comeback, as using quaternions for calculating rotations is more
numerically stable than traditional matrix calculations.

I've done considerable work with quaternions in physics engines
for simulation. Nobody in that area calls them "hypercomplex numbers".
The geometric concept is simple. Consider an angle represented
as a 2-element unit vector. It's a convenient angle representation.
It's homogeneous - there's no special case at 0 degrees.

Then upgrade to 3D. You can represent latitude and longitude
as a 3-element unit vector. (GPS systems do this; latitude and
longitude are only generated at the end, for output.)

Then upgrade to 4D. Now you have a 4-element unit vector
that represents latitude, longitude, and heading. It can
also be thought of as a point on the surface of a 4D sphere,
although that isn't too useful.

If you have to numerically integrate torques to get
angular velocity, and angular velocity to get angular position,
quaternions are the way to go. If you want to understand
all this, there's a good writeup in one of the Graphics Gems
books.

Unlike complex numbers, these quaternions are always unit vectors.

John Nagle
 
R

Roy Smith

John Nagle <[email protected]> said:
Then upgrade to 3D. You can represent latitude and longitude
as a 3-element unit vector. (GPS systems do this; latitude and
longitude are only generated at the end, for output.)

And annoyingly so. Somebody I know was building a tracking system based
on a PIC chip and a Trimble GPS module. The danged thing would only
give him lat/long, which he then had to devote a sizable chunk of his
very limited CPU power to converting into some more useful coordinate
system. Internally, the GPS module was certainly working in something
more useful than lat/long, but didn't expose that.

I've done similar math when doing some molecular modeling. Atoms are
free to rotate in 3-space around the inter-atomic bonds. You don't want
to have to worry about dividing by zero just because some rotation angle
is 0 or 90 or some other magic number.
 
D

Dennis Lee Bieber

If you have to numerically integrate torques to get
angular velocity, and angular velocity to get angular position,
quaternions are the way to go. If you want to understand
all this, there's a good writeup in one of the Graphics Gems
books.
There are a couple of texts dedicated just to quartenions...

http://www.amazon.com/s/ref=nb_sb_n...words=quarternions&rh=n:283155,k:quarternions

I have the Kuipers, may have the Vince -- though the date is
problematic; bought them as my prior job touched on them in some
applications, but as I was laid off in October 2011, haven't done much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top