| 1 | initial version |
When you write
sage: k = GF(9, 'a')
The Python name k points to the field with 9 elements:
sage: k
Finite Field in a of size 3^2
But the Python name a does not point to anything:
sage: a
NameError: name 'a' is not defined
If you want to get the generator of the field, you can do:
sage: k.gen()
a
sage: k.gen()^8
1
So, if you want the Python name to point to that generator of the field, you can just do:
sage: a = k.gen()
sage: a
a
sage: a^2
a + 1
sage: x = 2*a+1
sage: x
2*a + 1
sage: x^3
a
Now, Sage has some magic to do that, you could also do:
sage: k.inject_variables()
Defining a
Also, there is something else, which is convenient for mathematicians, but violates the Python language (there is a specific Sage preparsing behind the scenes), you can do:
sage: k.<a> = GF(9)
This defines both k and a at the same time.
| 2 | No.2 Revision |
When you write
sage: k = GF(9, 'a')
The Python name k points to the field with 9 elements:
sage: k
Finite Field in a of size 3^2
But the Python name a does not point to anything:
sage: a
NameError: name 'a' is not defined
If you want to get the generator of the field, you can do:
sage: k.gen()
a
sage: k.gen()^8
1
So, if you want the Python name a to point to that generator of the field, you can just do:
sage: a = k.gen()
sage: a
a
sage: a^2
a + 1
sage: x = 2*a+1
sage: x
2*a + 1
sage: x^3
a
Now, Sage has some magic to do that, you could also do:
sage: k.inject_variables()
Defining a
Also, there is something else, which is convenient for mathematicians, but violates the Python language (there is a specific Sage preparsing behind the scenes), you can do:
sage: k.<a> = GF(9)
This defines both k and a at the same time.
| 3 | No.3 Revision |
When you write
sage: k = GF(9, 'a')
The Python name k points to the field with 9 elements:
sage: k
Finite Field in a of size 3^2
But the Python name a does not point to anything:
sage: a
NameError: name 'a' is not defined
If you want to get the generator of the field, you can do:
sage: k.gen()
a
sage: k.gen()^8
1
So, if you want the Python name a to point to that generator of the field, you can just do:
sage: a = k.gen()
sage: a
a
sage: a^2
a + 1
sage: x = 2*a+1
sage: x
2*a + 1
sage: x^3
a
Now, Sage has some magic to do that, you could also do:do (it is very convenient for objects with several generators):
sage: k.inject_variables()
Defining a
Also, there is something else, which is convenient for mathematicians, but violates the Python language (there is a specific Sage preparsing behind the scenes), you can do:
sage: k.<a> = GF(9)
This defines both k and a at the same time.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.