Ask Your Question
0

what meanings about "xmrange_iter([[0, 1], [0, 1]], <function <lambda> at 0xb94ab1c>)"

asked 2014-01-07 20:52:37 -0500

cjsh gravatar image
K.<a> = NumberField(x^2 +26);K;I = K.ideal(2);show(I)
res =  I.residues(); res;show(list(res));res =  (2*I).residues(); res;show(list(res))



***xmrange_iter([[0, 1], [0, 1]], <function <lambda> at
0xb94ab1c>)***
[0,a,1,a+1]

***xmrange_iter([[-1, 0, 1, 2], [-1, 0, 1, 2]], <function <lambda>
at 0xb94abfc>)***
[?a?1,?1,a?1,2a?1,?a,0,a,2a,?a+1,1,a+1,2a+1,?a+2,2,a+2,2a+2]



I know [0, 1] is a coordinates but what meanings about "lambda","0xb94abfc"?
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2014-01-08 03:52:12 -0500

tmonteil gravatar image

updated 2014-01-08 03:56:46 -0500

A lambda function is a kind of anonymous map. For example:

sage: f = lambda x : 2*x

Says "f is the map that sends x to 2*x", and you can check:

sage: f(4)
8

It is anonymous because you can do:

sage: (lambda x : 3*x)(3)
9

Then, you can get the documentation of xmrange_iter by typing:

sage: xmrange_iter?

This makes your residues the image of a product by a map.

Indeed, the first part of res is the list of lists (to be understood as a product):

sage: res.iter_list
[[-1, 0, 1, 2], [-1, 0, 1, 2]]

and its second part is the map that has to be applied to any element of the product:

sage: res.typ
<function sage.rings.number_field.number_field_ideal.<lambda>>

This second argument is the lambda function you want to understand. Let us play with it:

sage: res.typ((-1,-1))
-a - 1
sage: res.typ((-1,0))
-1
sage: res.typ((0,1))
a
sage: res.typ((0,2))
2*a
sage: res.typ((3,2))
2*a + 3

I am sure you understand what does this lambda function!

Now, the list of residues is just the image of each element of the product $ \{-1, 0, 1, 2\} \times \{-1, 0, 1, 2\} $ by the map (u,v) --> u*1 + v*a , that is:

sage: list(res)
[-a - 1,
 -1,
 a - 1,
 2*a - 1,
 -a,
 0,
 a,
 2*a,
 -a + 1,
 1,
 a + 1,
 2*a + 1,
 -a + 2,
 2,
 a + 2,
 2*a + 2]

sage: res.cardinality()
16
edit flag offensive delete link more

Comments

http://xkcd.com/1258/ doesn't apply here, apparently :)

kcrisman gravatar imagekcrisman ( 2014-01-08 03:57:14 -0500 )edit

Hehe, the same just appeared the other way with [this question](http://ask.sagemath.org/question/3386/how-to-get-the-same-environment-in-sage-ipython), so i dramatically shortened my answer while posting.

tmonteil gravatar imagetmonteil ( 2014-01-08 04:17:23 -0500 )edit
1

answered 2014-01-08 03:56:12 -0500

kcrisman gravatar image
sage: K.<a> = NumberField(x^2 +26);K;I = K.ideal(2)
Number Field in a with defining polynomial x^2 + 26
sage: I
Fractional ideal (2)
sage: res =  I.residues()
sage: res
xmrange_iter([[0, 1], [0, 1]], <function <lambda> at 0x111a0cc08>)
sage: type(res)
<type 'instance'>

What you see from this is that I.residues, as stated in its documentation,

   Returns a iterator through a complete list of residues modulo this
   integral ideal.

An iterator is basically something you can iterate through in a loop or list. If you just do

sage: list(res)
[0, a, 1, a + 1]

you get what you expect, I think. But when you just put res then it tells you what res it, instead of looping through it or listing it - and it's an xmrange_iter Sage object, complete with a Cartesian product and a function applied to them which is the type. See

sage: xmrange_iter?

for more details. It is not really something worry about, though; just make your lists as normal.

edit flag offensive delete link more
0

answered 2014-01-09 20:24:50 -0500

cjsh gravatar image

thank you very much!

lambda and xmrange_iter is very good function!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-01-07 20:52:37 -0500

Seen: 129 times

Last updated: Jan 09 '14