To save a record of your Gap session enter something like gap> LogTo("filename"); or gap> LogTo("may10.07a"); In fact I did this on Gap just before the first line you can read above. Naturally, when done I looked at this file and edited it for appearance, removed Gap error messages, the Gap prompts before the current line, etc. There are a couple of ways to write your own Gap functions and programmes. The quickest way, especially for simple functions, is to directly enter the command. For example, if you want Gap to take as input a permutation p and give as output p, p^2 ... p^5 enter this: gap> pow:=p->[p,p^2,p^3,p^4,p^5]; function( p ) ... end gap> pow( (1,2,3,4,5) ); [ (1,2,3,4,5), (1,3,5,2,4), (1,4,2,5,3), (1,5,4,3,2), () ] gap> pow( (1,2)*(2,3)*(3,4) ); [ (1,4,3,2), (1,3)(2,4), (1,2,3,4), (), (1,4,3,2) ] However, for editing, debugging and future use, it is often better to independently create the function in a separate file, say wombat, then read it in usuing the Gap command Read("wombat"); note that file names inside Gap come between double quotes. That way, if there is a goof, you can edit and Read the file again, etc. For eample, suppose in your text editor you compose a file called wombat with the following lines: newpow:= function(p) local j; # stuff after a # is ignored for j in [1..5] do Print("power j = ",j," gives ", p^j,"\n","Have nice day!","\n"); od; end; # end of this silly function Then the command gap> Read("wombat"); silently imports the function newpow for your use: gap> newpow( (1,2)*(2,3)*(3,4) ); power j = 1 gives (1,4,3,2) Have nice day! power j = 2 gives (1,3)(2,4) Have nice day! power j = 3 gives (1,2,3,4) Have nice day! power j = 4 gives () Have nice day! power j = 5 gives (1,4,3,2) Have nice day! Exercise 1: Write a Gap function ref with input m which produces the 2 x 2 orthoogonal matrix for reflection in the line y = mx. Remark: Gap can't do general sines and cosines, so we could take the following approach for rotations. Exercise 2: Assuming ref is available in the background, write a function rot of (m,n) which produces the rotation matrix for the product of reflections in lines of slope m and n. Regarding trigonometric functions we can actually do something, since exp(2*pi*i/n) = cos(2*pi/n) + i sin(2*pi*n) is an important `algebraic number' and hence comes built into Gap. The penalty is that simple rela numbers might end up expressed as messy combinations of complex numbers. Exercise 3: Find out about Gaps way of dealing with cyclotomic field involving the complex number z := exp(2*pi*i/n) = cos(2*pi/n) + i sin(2*pi*n). Now given an input rational number r, find out how to get the numerator and denominator of r. Next write a function rotrat of r which gives the 2 x 2 orthogonal rotation matrix for an angle of r degrees. *************************************** We can represent the line ax + by = c in the PLANE using the row vector [a,b,-c] and the point (x,y) by the column with entries x,y,1; Actually in Gap this would be [[a,b,-c]] and [[x],[y],[1]], as in gap> line:=[[2,3,-4]]; A:=[[11],[-6],[1]];B:=[[10],[-6],[1]];; [ [ 2, 3, -4 ] ] [ [ 11 ], [ -6 ], [ 1 ] ] gap> Display(line);Display(A);Display(B); [ [ 2, 3, -4 ] ] [ [ 11 ], [ -6 ], [ 1 ] ] [ [ 10 ], [ -6 ], [ 1 ] ] gap> line*A;line*B; [ [ 0 ] ] [ [ -2 ] ] Thus A lies on the line but B doesn't. Exercise 4. Write a function glide whose input is a 3 x 3 matrix L whose rows are the line vectors for three lines, something like [ a1, b1, -c1] L = [ a2, b2, -c2] (this isn't quite correct Gap syntax). [ a3, b3, -c3] In actual use, the input will be a concrete matrix like gap> L:=[[1,2,3],[4,5,6],[9,8,7]];; (So the third line here has equation 9x + 8y = -7) The output should be a list of three things: first: a 3 by 2 matrix whose two columns are the initial point A and terminal point B for the glide step AB (this means the axis is line AB and the parallel shift is vector AB). Note that the bottom row of this matrix should be [[1,1]], according to how we represent points in the plane by three dimensional columns. second: the row vector for the equation of the axis line third: the length of the glide step (same as length of segment AB). Remark: input data will typically be rational numbers; output three may require roots; so you will have to be sure Gap is happy to take square roots. This should work but may need a bit of fussing. Enhancement: give a separate output indication when the glide degenerates to an ordinary reflection; and in this case print the line vector for the mirror, If you want to be really fancy, give text output, as in the The glide has axis 3x + 5y = 7 and step length root(12).