Ask Your Question
0

How do I get that sage prints me out some item

asked 2020-06-09 11:56:10 -0600

Moondoggy gravatar image

I have the following code:

      sage:R.<x>=QQ[]
               f=x^2-x+6
           K.<a>=NumberField(f)
               cl = K.class_group()
                 L=K.ideal(23)
                 S=ideal(4,a+1)
                S.is_integral()
      sage: for norm, ideals in K.ideals_of_bdd_norm(50).items():
    for J in ideals:
        for N in range(5):
            if (J.is_coprime(L*N)):
                if(J!=cl.one()):
                    if(4*J.norm()-1 in L*N): 
                         print norm,J,N

The output is :

True
6 Fractional ideal (6, a + 2) 1
6 Fractional ideal (a - 1) 1
6 Fractional ideal (a) 1
6 Fractional ideal (6, a + 3) 1
29 Fractional ideal (29, a + 18) 1
29 Fractional ideal (29, a + 10) 1

What do I have to do to only get the item 29 Fractional ideal (29, a + 18) 1 ?

edit retag flag offensive close merge delete

Comments

Can you provide more information? How, computationally or programmatically or mathematically, do you want to choose which item to print/return?

John Palmieri gravatar imageJohn Palmieri ( 2020-06-09 16:13:35 -0600 )edit

I only want to know whether there is a command to select a specific item for example 29 Fractional ideal (29, a + 18) 1.

Moondoggy gravatar imageMoondoggy ( 2020-06-09 17:14:20 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-06-10 14:06:35 -0600

Instead of:

sage: for a in [0,1,2]:
....:     print(a**2)
....:         
0
1
4

do

sage: L = []
sage: for a in [0,1,2]:
....:     L.append(a**2)
....:     
sage: L
[0, 1, 4]

Then you have access to the list L, you can pick and choose elements from it, etc. For example:

sage: L[2]
4
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

1 follower

Stats

Asked: 2020-06-09 11:56:10 -0600

Seen: 46 times

Last updated: Jun 10