Re: [sage-devel] Re: norm of a complex number

2010-04-29 Thread Minh Nguyen
Hi Johan,

2010/4/30 Johan Grönqvist :



> I tried following the guides, but it is my first attempt at using both
> mercurial and trac, so I may well have missed something.

I have looked over the patch. It is very good. I'm reviewing it now to
determine what more to add to your patch so as to prevent future
incidents of confusion over the function "norm()".

-- 
Regards
Minh Van Nguyen

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-29 Thread Johan Grönqvist

2010-04-27 11:37, Minh Nguyen skrev:

Would you upload a patch
to the trac server to improve that documentation? If so, please CC me
on the relevant ticket and I'd be more than happy to review your
patch.


I have opened ticket 8825 and attached a patch. It is a very small 
change, and by no means complete. It merely adds two more examples to 
the docstring and is intended to display the inconsistency in usage of 
the term norm in sage.


I tried following the guides, but it is my first attempt at using both 
mercurial and trac, so I may well have missed something. The patch is 
against sage-4.4.rc0.


Regards

Johan

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-27 Thread Dima Pasechnik
To summarize:

What is norm for number theorists, is pathology to the ordinary folks!
:-)


On Apr 27, 8:25 pm, Johan Grönqvist  wrote:
> 2010-04-27 13:29, Gonzalo Tornaria skrev:
>
> > 2010/4/27 Johan Grönqvist:
> >> Those did not even mention that
> >> there is an alternative definition of norm used in number theory.
>
> > Here it is:http://en.wikipedia.org/wiki/Field_norm
>
> Thanks. Now I learned something new.
>
> >> The norm on complex numbers is not consistent with viewing the complex
> >> numbers as a two-dimensional real vector space, according to the 
> >> definitions
> >> mentioned above.
>
> > One caveat: "the" norm of a two-dimensional real vector space is not
> > canonical. In contrast, the norm of a two-dimensional field extension
> > is uniquely defined.
>
> True, but the argument was not about the particular choice of norm, but
> the property
>
> norm(a*v) == abs(a) * norm(v)  [for any scalar a and any vector v]
>
> required for any vector-space norm. That property does not seem to hold
> for the field norm.
>
> Regards
>
> Johan
>
> --
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group athttp://groups.google.com/group/sage-devel
> URL:http://www.sagemath.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-27 Thread Johan Grönqvist

2010-04-27 13:29, Gonzalo Tornaria skrev:

2010/4/27 Johan Grönqvist:

Those did not even mention that
there is an alternative definition of norm used in number theory.


Here it is: http://en.wikipedia.org/wiki/Field_norm



Thanks. Now I learned something new.


The norm on complex numbers is not consistent with viewing the complex
numbers as a two-dimensional real vector space, according to the definitions
mentioned above.


One caveat: "the" norm of a two-dimensional real vector space is not
canonical. In contrast, the norm of a two-dimensional field extension
is uniquely defined.



True, but the argument was not about the particular choice of norm, but 
the property


norm(a*v) == abs(a) * norm(v)  [for any scalar a and any vector v]

required for any vector-space norm. That property does not seem to hold 
for the field norm.


Regards

Johan

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: norm of a complex number

2010-04-27 Thread Gonzalo Tornaria
2010/4/27 Johan Grönqvist :
> The definition of norm on vectors is consistent with definitions of norm
> according to wikipedia [0] and the springer encyclopedia of mathematics [1],
> and (I believe) any book I have ever used. Those did not even mention that
> there is an alternative definition of norm used in number theory.

Here it is: http://en.wikipedia.org/wiki/Field_norm

> The norm on complex numbers is not consistent with viewing the complex
> numbers as a two-dimensional real vector space, according to the definitions
> mentioned above.

One caveat: "the" norm of a two-dimensional real vector space is not
canonical. In contrast, the norm of a two-dimensional field extension
is uniquely defined.

In the case of Sage, the norm of complex numbers is defined as the
norm for the field extension C over R.

Gonzalo

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-27 Thread YannLC


On Apr 27, 10:06 am, Johan Grönqvist 
wrote:
>
> The concept of a norm, as I have always encountered it, is well defined,
> as in e.g. wikipedia[0] and other mathematics encyclopedias [1], [2], as
> well as (I belive) any book I have used. This refers to vector spaces,
> and I expect that most people use norms on vector spaces.

Just to add a link for people interested, the norm used now for
complex numbers comes from "field theory" [0]

[0] http://en.wikipedia.org/wiki/Field_norm

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-27 Thread Johan Grönqvist

2010-04-27 11:37, Minh Nguyen skrev:

Hi Johan,

2010/4/27 Johan Grönqvist:

The current documentation of norm() on complex numbers can be accessed
from the Sage website [1]. That documentation leaves much to be
desired, even though it makes the distinction between the complex norm
and the absolute value of a complex number.


That documentation is much better than what I looked at. That certainly 
satisfies my request for documentation.



Would you upload a patch
to the trac server to improve that documentation? If so, please CC me
on the relevant ticket and I'd be more than happy to review your
patch.



I would like to improve the following case.

--
sage: norm?
Type:   function
Base Class: 
String Form:
Namespace:  Interactive
File:	 
/home/johan/Debian/sage-4.4.rc0/local/lib/python2.6/site-packages/sage/misc/functional.py

Definition: norm(x)
Docstring:
   Returns the norm of x.

   EXAMPLES:

  sage: z = 1+2*I
  sage: norm(z)
  5
  sage: norm(CDF(z))
  5.0
  sage: norm(CC(z))
  5.00
---

In particular I would like it to remark that the norm of the one element 
vector is not the same as the norm of the element (for a complex number).


I hope to look at it later this week.

Thanks for your reply


Regards

Johan






[1] 
http://www.sagemath.org/doc/reference/sage/rings/complex_number.html#sage.rings.complex_number.ComplexNumber.norm




--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: norm of a complex number

2010-04-27 Thread Minh Nguyen
Hi Johan,

2010/4/27 Johan Grönqvist :



> My suggestion is to change the definition of norm on complex numbers.
>
> If that is not changed, I think that the docstring should clearly state that
> sage deviates from the definitions of norm used by wikipedia, springer,
> mathematica, maple and matlab, as I expect most people from physics and
> engineering expect sage to follow the same definition as those.

The current documentation of norm() on complex numbers can be accessed
from the Sage website [1]. That documentation leaves much to be
desired, even though it makes the distinction between the complex norm
and the absolute value of a complex number. Would you upload a patch
to the trac server to improve that documentation? If so, please CC me
on the relevant ticket and I'd be more than happy to review your
patch.

[1] 
http://www.sagemath.org/doc/reference/sage/rings/complex_number.html#sage.rings.complex_number.ComplexNumber.norm

-- 
Regards
Minh Van Nguyen

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-27 Thread Johan Grönqvist

2010-04-26 21:26, John Cremona skrev:


In number theory it is very useful to have this norm-alisation, as
well as the square root one also called abs.  It's a special case of
the algebraic concept of norm(a) = product of conjugates of a.

If this was really a problem to non-number-theorists, we could
possibly  live with it (possibly by defining a new function for this).

Other opinions may differ...




[Note: I come from physics, and do not use sage very much, but I would 
like to replace my usage of mathematica/maple with sage.]



Short version:

I am surprised by

sage: norm(1+I)
2
sage: norm(vector([1+I]))
sqrt(2)

and I think sage should choose to change the definition of norm used on 
complex numbers, as it wants to grow a broader user base.


The definition of norm on vectors is consistent with definitions of norm 
according to wikipedia [0] and the springer encyclopedia of mathematics 
[1], and (I believe) any book I have ever used. Those did not even 
mention that there is an alternative definition of norm used in number 
theory.


The norm on complex numbers is not consistent with viewing the complex 
numbers as a two-dimensional real vector space, according to the 
definitions mentioned above.






Long version:

I am very surprised by the current terminology. I think that many users 
coming from physics and engineering would be surprised, and the mission 
statement of sage, "Creating a viable free open source alternative to 
Magma, Maple, Mathematica and Matlab", certainly seems to aim at a much 
broader user community than number-theorists.


I would be very surprised if any of mathematica, maple and matlab used 
the same convention as sage does, and given the mission statement, I 
think that common terminology is a good thing.


The concept of a norm, as I have always encountered it, is well defined, 
as in e.g. wikipedia[0] and other mathematics encyclopedias [1], [2], as 
well as (I belive) any book I have used. This refers to vector spaces, 
and I expect that most people use norms on vector spaces.


One property a norm is required to have is that for any vector v and 
scalar a:


norm(a*v) == abs(a) * norm(v)

this holds for vectors

sage: norm( (1+I) * vector([1+I]) )
2
sage: abs(1+I) * norm( vector([1+I]) )
2

but not for complex numbers seen as 2-dimensional real vectors:

sage: norm( 2 *  (1+I) )
8
sage: abs(2) * norm(1+I)
4


Regardless of that part, I think many people would, like me, be 
surprised by the following results:


sage: norm(1+I)
2
sage: norm(vector([1+I]))
sqrt(2)

I find it very strange that the one element vector does not have the 
same norm as the element it contains.


My suggestion is to change the definition of norm on complex numbers.

If that is not changed, I think that the docstring should clearly state 
that sage deviates from the definitions of norm used by wikipedia, 
springer, mathematica, maple and matlab, as I expect most people from 
physics and engineering expect sage to follow the same definition as those.



Regards

Johan



[0]: 
[1]: 
[2]: 



--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-26 Thread kcrisman
I'm used to the number-theoretic norm too, so I wasn't so worried
about it.   I would point out that having "native" support of Gaussian
integers/primes would be very convenient for educational purposes (for
instance, a.is_prime() is not implemented for SR, but unfortunately
also not for these guys... and I know it's not clear inside of which
ring a should be prime, so don't even complain about that).

On Apr 26, 4:09 pm, John Cremona  wrote:
> This is certainly a bug:
>
> sage: a = sqrt(-3)
> sage: a
> sqrt(-3)
> sage: a.conjugate()
> sqrt(-3)
>
> sage: bool(a==a.conjugate())
> True
>

Yeah, this is bad, and according to a.conjugate?? it seems to be
something wrong with our Ginac/Pynac use. Maybe a.conjugate() on SR
needs to only be automatically evaluated on things that can coerce to
RR or ZZ?  It is possible that http://trac.sagemath.org/sage_trac/ticket/6244
is directly related, but I'm too lazy to see which Pynac changeset
this is related to.

Related (though not directly) tickets are 
http://trac.sagemath.org/sage_trac/ticket/7957,
http://trac.sagemath.org/sage_trac/ticket/7916, and
http://trac.sagemath.org/sage_trac/ticket/6862.

I've made this http://trac.sagemath.org/sage_trac/ticket/8775 and
marked it critical.  Would be good to fix for 4.4.1.

- kcrisman

- kcrisman

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-26 Thread Jason Grout

On 04/26/2010 02:48 PM, Gonzalo Tornaria wrote:

On Mon, Apr 26, 2010 at 4:26 PM, John Cremona  wrote:

In number theory it is very useful to have this norm-alisation, as
well as the square root one also called abs.  It's a special case of
the algebraic concept of norm(a) = product of conjugates of a.


And the determinant of the action of a on C (as an R-vector space of
dimension 2) by complex multiplication.



I figured there were good mathematical reasons---I just wanted to know 
how to address the issue if it came up in conversation or teaching.


I'll leave the inconsistencies/bugs noted elsewhere in this thread to 
someone else to file a trac ticket or track them down.


Thanks,

Jason

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: norm of a complex number

2010-04-26 Thread Rishikesh
There is abs() function which behaves likes Norm of Mathematica. I
think that the function names of sage are more appropriate.

Rishi

On Apr 26, 3:26 pm, John Cremona  wrote:
> In number theory it is very useful to have this norm-alisation, as
> well as the square root one also called abs.  It's a special case of
> the algebraic concept of norm(a) = product of conjugates of a.
>
> If this was really a problem to non-number-theorists, we could
> possibly  live with it (possibly by defining a new function for this).
>
> Other opinions may differ...
>
> John
>
> On 26 April 2010 20:21, Jason Grout  wrote:
>
>
>
>
>
> > Why does Sage say the norm of a complex number a+b*I is a^2+b^2?
>
> > sage: norm(1+2*I)
> > 5
>
> > In MMA:
>
> > In[1]:= Norm[1+2*I]
>
> > Out[1]= Sqrt[5]
>
> > Wikipedia and mathworld both agree that the norm should be sqrt(5) (i.e.,
> > the square root of the number times its conjugate).
>
> > Note that abs() seems right:
>
> > sage: abs(1+2*I)
> > sqrt(5)
>
> > Thanks,
>
> > Jason
>
> > --
> > To post to this group, send an email to sage-devel@googlegroups.com
> > To unsubscribe from this group, send an email to
> > sage-devel+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/sage-devel
> > URL:http://www.sagemath.org
>
> --
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group athttp://groups.google.com/group/sage-devel
> URL:http://www.sagemath.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org