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

2013-10-16 Thread Roy Smith
In article , John Nagle  
wrote:

> 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-15 Thread John Nagle
On 10/10/2013 6:27 PM, Steven D'Aprano wrote:
> 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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread Gene Heskett
On Friday 11 October 2013 12:49:40 Roy Smith did opine:

> In article ,
> 
>  Oscar Benjamin  wrote:
> > 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:
> 
> http://www.youtube.com/watch?v=jG7vhMMXagQ

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.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread Steven D'Aprano
On Fri, 11 Oct 2013 10:05:03 -0400, Roy Smith wrote:

> In article ,
>  Oscar Benjamin  wrote:
> 
>> 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:

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).



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread Roy Smith
In article ,
 Oscar Benjamin  wrote:

> 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:

http://www.youtube.com/watch?v=jG7vhMMXagQ
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread Jussi Piitulainen
Oscar Benjamin writes:

> 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.


-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread Oscar Benjamin
On 11 October 2013 10:35, David  wrote:
> On 11 October 2013 12:27, Steven D'Aprano
>  wrote:
>> On Fri, 11 Oct 2013 00:25:27 +1100, Chris Angelico wrote:
>>
>>> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
 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.
> [...]
>> 
>
> 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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread Nobody
On Thu, 10 Oct 2013 14:12:36 +, Grant Edwards wrote:

> Nope.  "i" is electical current (though it's more customary to use upper
> case).

"I" is steady-state current (either AC or DC), "i" is small-signal
current.

-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-11 Thread David
On 11 October 2013 12:27, Steven D'Aprano
 wrote:
> On Fri, 11 Oct 2013 00:25:27 +1100, Chris Angelico wrote:
>
>> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
>>> 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.
[...]
> 

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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 11:13 AM, Dennis Lee Bieber
 wrote:
> On Fri, 11 Oct 2013 01:20:01 +1100, Chris Angelico 
> declaimed the following:
>
>>
>>This belongs in the Izzet League, I think.
>>
> 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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Steven D'Aprano
On Fri, 11 Oct 2013 00:25:27 +1100, Chris Angelico wrote:

> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
>> 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. 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.



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.



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread David
On 11 October 2013 06:29, Oscar Benjamin  wrote:
>
> I learned to use i for sqrt(-1) while studying theoretical physics.
> When I later found myself teaching maths to engineers I asked why j
> was used and was given this explanation. I'm still unconvinced by it
> though.

Please don't be. We need different symbols to distinguish between so
many different aspects of current (average, dynamic, instantaneous,
rms, peak, sinusoidal-amplitude, sinusoidal-phasor) that we use up all
possible variations of bold, italic, subscript just to distinguish those
different aspects of i. It gets confusing enough as it is, because typically
we are describing many current variables (in one or more of the above
aspects) simultaneously, not just one. And the same holds for current
density, but less common. That's why we prefer j for sqrt(-1), not because
we are unconvincing :)
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Oscar Benjamin
On 10 October 2013 15:34, David  wrote:
> On 11 October 2013 00:25, Chris Angelico  wrote:
>> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
>>
>> 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?
>
> Pretty well covered here: http://en.wikipedia.org/wiki/Complex_number
>
> Plus, the simple overview is that they are useful because they are
> two-dimensional, and so can be used to simply calculations involving
> two-dimensional quantities. Very useful for electrical engineers who
> use them to represent the two dimensions of amplitude,phase in
> Fourier or Laplace circuit analysis. As others have pointed out, they
> use the symbol j for the square root of -1 to avoid confusion with the
> symbol i used for current.

I learned to use i for sqrt(-1) while studying theoretical physics.
When I later found myself teaching maths to engineers I asked why j
was used and was given this explanation. I'm still unconvinced by it
though. Physicists also have to deal with electric currents but they
can happily distinguish these two with upper and lower case. Upper
case J is used in electrodynamics for the "free" current density.
Lower case j is used by both engineers and physicists to denote a unit
vector in the "y-direction" though it would usually be in non-italic
bold-face when used in that context.

> I have never heard the term "hypercomplex" numbers. I guess you
> are referring to vectors with more dimensions than two. A three
> dimensional vector is described as having components in i,j,k
> directions. Although this is very like an extension of complex numbers
> into higher dimensions, the symbols used (i,j,k) are not the same
> as the i or j used for complex numbers. Instead they represent
> orthogonal unit vectors; which are similar in concept (because
> real and imaginary components of complex numbers are orthogonal),
> but not the *same*. So don't think of the i *or* j of a complex number
> being related to the i *and* j etc components of a vector.
>
> These are useful for example to describe three dimensional space, and
> scalar or vector functions in that space.

I've never heard the term "hypercomplex" before either although I did
intuitively understand its meaning (quaternions, octonions etc). These
are also useful in a number of contexts. For example, quaternions are
often used to represent orientations in 3D physical simulations
(including computer games). A quaternion is usually represented with
the basis i, j, k and 1 where a complex number would just have 1 and i
(or 1 and j if you're an engineer).


Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Christian Gollwitzer

Am 10.10.13 18:54, schrieb Grant Edwards:

On 2013-10-10, Chris Angelico  wrote:

On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards  wrote:

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.


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)


But they are very useful to represent 3D-rotation around an inclined 
axis (look up quaternion rotation). I don't know whether EEs work in 
aircraft navigation, but I suspect they do ;)


Christian

--
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Ethan Furman

On 10/10/2013 07:20 AM, Chris Angelico wrote:

On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards wrote:


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.


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.  ;)

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Grant Edwards
On 2013-10-10, Chris Angelico  wrote:
> On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards  
> wrote:
>> 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.
>
> 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.

-- 
Grant Edwards   grant.b.edwardsYow! I want EARS!  I want
  at   two ROUND BLACK EARS
  gmail.comto make me feel warm
   'n secure!!
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread William Ray Wing
On Oct 10, 2013, at 10:12 AM, Grant Edwards  wrote:

> On 2013-10-10, Chris Angelico  wrote:
>> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
>>> 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,
> 
> Nope.  "i" is electical current (though it's more customary to use
> upper case).  "j" is the square root of -1.
> 

It all depends on where (in what field) you learned about complex numbers.  
Mathematicians and Physicists use i, engineers use j.

-Bill 

-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread rusi
On Thursday, October 10, 2013 8:04:00 PM UTC+5:30, David wrote:
> I have never heard the term "hypercomplex" numbers. I guess you
> are referring to vectors with more dimensions than two. A three

A generalization of quaternions :
http://en.wikipedia.org/wiki/Hypercomplex_number
http://en.wikipedia.org/wiki/Quaternion

And now where's the policeman out to catch the OT threads??
[Ducks the eggs and runs...]
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread David
On 11 October 2013 00:25, Chris Angelico  wrote:
> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
>
> 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?

Pretty well covered here: http://en.wikipedia.org/wiki/Complex_number

Plus, the simple overview is that they are useful because they are
two-dimensional, and so can be used to simply calculations involving
two-dimensional quantities. Very useful for electrical engineers who
use them to represent the two dimensions of amplitude,phase in
Fourier or Laplace circuit analysis. As others have pointed out, they
use the symbol j for the square root of -1 to avoid confusion with the
symbol i used for current.

I have never heard the term "hypercomplex" numbers. I guess you
are referring to vectors with more dimensions than two. A three
dimensional vector is described as having components in i,j,k
directions. Although this is very like an extension of complex numbers
into higher dimensions, the symbols used (i,j,k) are not the same
as the i or j used for complex numbers. Instead they represent
orthogonal unit vectors; which are similar in concept (because
real and imaginary components of complex numbers are orthogonal),
but not the *same*. So don't think of the i *or* j of a complex number
being related to the i *and* j etc components of a vector.

These are useful for example to describe three dimensional space, and
scalar or vector functions in that space.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards  wrote:
> 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.
>

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
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Grant Edwards
On 2013-10-10, Chris Angelico  wrote:
> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
>> 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,

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. 

;)

-- 
Grant Edwards   grant.b.edwardsYow! Are we THERE yet?
  at   My MIND is a SUBMARINE!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Robin Becker

On 10/10/2013 14:25, Chris Angelico wrote:

On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:

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


Electrical Engineers  use j (probably to avoid conflicts with i (current).
--electrically yrs--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list


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

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith  wrote:
> 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
-- 
https://mail.python.org/mailman/listinfo/python-list