/* MAGMA */ // (This shows you the two possible ways of making a comment in // Magma) /* 1 - Introduction Magma is a powerfull system for doing algebra. The object of This course is to show you how to use Magma to explore some of the topics in the Algebra 3 class 1.1 - How to get help Magma has an extensive help facility. There is online documentation: under the Magma directory (/usr/local/magma) go to subdirectory htmlhelp and start the browser on MAGMA.html. The documentation is also available in dvi, ps and pdf formats. You can get help within Magma as follows */ ? // or if you want help on a particular topic, e.g. elliptic curves ?elliptic // or you can use the help browser ?? /* 1.2 Starting and exiting You start Magma by giving the command "magma", you exit by giving the command quit; or typing -D 1.3 How to execute the example files. A good way to use Magma is inside emacs: Start emacs. Enter the command -x shell This enters shell-mode. You have a prompt, at which you type magma Now, read in the example file, e.g., this file "lecture1" by giving the command -x i lecture1 Now, you see all the lines of the example on your scree. Each time you go to the end of the line and type all lines up to that point which have not yet been executed are executed. 1.4 Loading definitions A file containing definitions, e.g., function definitions, can be loaded using the command load "file"; 1.5 Logging a session Logging a sesstion is done by the command */ SetLogFile("Logfile"); /* You stop logging by the command UnsetLogFile(); We will see an example later 1.6 A few usefull tips -c interupts the execution of commands. If this does not work -\ exits Magma. If you want to save the current state of the workspace you can give the command */ save "FILENAME"; /* and we can go back to the same state by giving the command restore "FILENAME"; 2 - Basics 2.1 - expressions Every expression in Magma should end with a ";" */ 2+3; /* If you forget the ; the command will not execute but you can then enter the ; to execute it. */ 3+7 /* This gives you the possibility of splitting the input over several lines */ 1+ 2+ 3; /* 2.2 Printing The command "print" prints whatever comes after it */ print 3*4; /* Use of "print" is needed inside functions and procedures. You can print text as follows: */ " The greates common divisor of 15 and 10 is ", GCD(15,10); /* 2.3 Identifyer assignment Identifyers, which can be variables, function names and so on, are assigned values using ":=" as follows: */ aA := 7; Aa := 9; aA- Aa; f := PreviousPrime; // is is assigned the function PreviousPrime f(108); /* 2.4 Magmas and types The basic data structure in Magma is (obviously) a "Magma" - a set with some operation. Examples are fields, groups and rings Every object in Magma will have some type. The command "Type" gives this */ Type(2); /* This means 2 is an element in the ring of integers. We can get this ring itself as the parent of 2 */ Z := Parent(2); Z; Category(Z); // Category means the same as Type /* A more standard way of defining the integers is the following: */ Z := IntegerRing(); Type(Z); /* Other well known objects that can be defined are the rational, real and complex numbers */ Q := RationalField(); Q, Type(Q); R := RealField(); R; RR := RealField(20); // Real numbers of precision 20 RR; C15 := ComplexField(15); C15; // Now let us pose, stop logging and see what we have in the log file UnsetLogFile(); /* 2.5 Defining new types Unlike systems like Mathematica, one can't do symbolic manipulations immediately. */ (1+x)^10; /* Instead, you should first tell Magma where this object lies */ PP := PolynomialRing(IntegerRing()); PP; P := PolynomialRing(IntegerRing()); P; /* The meaning of this statement is this: P is the ring of polynomials in one variable. In the second statement, we give the name x to the variable of the ring. */ ?PolynomialRing /* Now x has a well defined meaning and we can do computations with it */ Type(x); (1+x)^10; /* 2.6 Sets Magma tries to use notation and data structures similar to standard mathematical notation and objects. One of the basic data structures is Sets, or indexed sets. Sets can even be infinite. */ S := {2,4,5,8,9}; S; T := {x^2 : x in S| IsPrime(x)}; T; /* Just like in mathematics, there are no repetions in sets */ {2} eq {2,2}; /* A sequence is an ordered set. Of special importance is the sequence [n..m] or [n..m by k] Here is an example. We find all solutions to a^2+b^2=c^2 with a b c less or equal to 10 */ squares := {c^2 : c in [1..10]}; { : a in [1..10], b in [1..10] | b ge a and (a^2+b^2) in squares }; /* This can be done slightly better by using "where .. is" notation */ { : a in [1..10], b in [1..10] | b ge a and (a^2+b^2) in sq } where sq is {c^2 : c in [1..10]}; /* We can also get the c by using indexed sets */ { : a in [1..10], b in [1..10], c in [1..10] | b ge a and (a^2+b^2) in sq and (a^2+b^2) eq sq[c]} where sq is {@ c^2 : c in [1..10] @}; /* In this example we see how to construct indexed set, and that the elements of an indexed set can be accessed via index. We also see an example of a tuple . We will learn more about tuples later. 3. Matrix groups In the course you learn the concept of a group. Then all types of groups become examples of groups. The situation in Magma is slightly different, since different types of groups require different algorithms. Today we will only learn about matrix groups. Next time we will learn much more about permutation groups. 3.1 The general linear group. The general linear group of degree n over a ring R is the group of all invertible nxn matrices with entries in a R. Examples of rings that we know already are: integers, rational, reals, complex numbers, finite field with prime p elements, ring of numbers modulo n. */ Q := RationalField(); G := GL(2,Q); H := GL(3,5); // 3x3 matrices over the field with 5 elements /* We can create elements of the general linear group as follows: */ g := elt; g1 := elt; h := elt; /* We can do group operations with these elements */ g*g1; // product of elements g^3; // power of element g^(-1); // inverse of element g/g1; g1^g; // conjugate of g1 by g, equal to g^-1 g1 g /* We can do much more if the group is finite. The group H is finite. We can ask Magma this: */ IsFinite(H); // We can also find the order of H #H; // There is another way of doing this c,d := IsFinite(H); c,d; /* Since the group H is finite, every element of H has finite order, i.e., some power of it will be the identity element. */ Order(h); h^2; h^2 eq Identity(H); Here we check experimentally that the multiplicative group of a finite field is cyclic, for prime fields of size up to 1000 */