Skip to main content

Exercises 6.7 Sage Exercises

The following exercises are less about cosets and subgroups, and more about using Sage as an experimental tool. They are designed to help you become both more efficient, and more expressive, as you write commands in Sage. We will have many opportunities to work with cosets and subgroups in the coming chapters. These exercises do not contain much guidance, and get more challenging as they go. They are designed to explore, or confirm, results presented in this chapter or earlier chapters.

Important: You should answer each of the last three problems with a single (complicated) line of Sage that concludes by outputting True. A “single line” means you will have several Sage commands packaged up together in complicated ways. It does not mean several Sage commands seperated by semi-colons and typed in on a single line. Be sure include some intermediate steps used in building up your solution, but using smaller ranges of values so as to not overwhelm the reader with lots of output. This will help you, and the grader of your work, have some confidence that the final version is correct.

When you check integers below for divisibility, remember that range() produces plain integers, which are quite simple in their functionality. The srange() command produces Sage integers, which have many more capabilities. (See the last exercise for an example.) And remember that a list comprehension is a very compact way to examine many possibilities at once.


Use .subgroups() to find an example of a group \(G\) and an integer \(m\text{,}\) so that (a) \(m\) divides the order of \(G\text{,}\) and (b) \(G\) has no subgroup of order \(m\text{.}\) (Do not use the group \(A_4\) for \(G\text{,}\) since this is in the text.) Provide a single line of Sage code that has all the logic to produce the desired \(m\) as its output. (You can give your group a simple name on a prior line and then just reference the group by name.) Here is a very simple example that might help you structure your answer.


Verify the truth of Fermat's Little Theorem (either variant) using the composite number \(391=17\cdot 23\) as the choice of the base (either \(a\) or \(b\)), and for \(p\) assuming the value of every prime number between \(100\) and \(1000\text{.}\)

Build up a solution slowly — make a list of powers (start with just a few primes), then make a list of powers reduced by modular arithmetic, then a list of comparisons with the predicted value, then a check on all these logical values resulting from the comparisons. This is a useful strategy for many similar problems. Eventually you will write a single line that performs the verification by eventually printing out True. Here are some more hints about useful functions.


Verify that the group of units mod \(n\) has order \(n-1\) when \(n\) is prime, again for all primes between \(100\) and \(1000\text{.}\) As before, your output should be simply True, just once, indicating that the statement about the order is true for all the primes examined. As before, build up your solution slowly, and with a smaller range of primes in the beginning. Express your answer as a single line of Sage code.


Verify Euler's Theorem for all values of \(0\lt n\lt 100\) and for \(1\leq a \leq n\text{.}\) This will require nested for statements with a conditional. Again, here is a small example that might be helpful for constructing your one line of Sage code. Note the use of srange() in this example.


The symmetric group on \(7\) symbols, \(S_7\text{,}\) has \(7! = 5040\) elements. Consider the following questions without employing Sage, based on what we know about orders of elements of permutation groups (Exercise 5.4.13).

  • What is the maximum possible order?

  • How many elements are there of order \(10\text{?}\)

  • How many elements are there of order \(1\text{?}\)

  • How many elements are there of order \(2\text{?}\)

  • What is the smallest positive integer for which there is no element with that order?

These questions will be easier if you are familiar with using binomial coefficients for counting in similarly complex situations. But either way, give some serious thought to each question (and maybe a few of your own) before firing up Sage.

Now, compute how many elements there are of each order using the .order() method, and then embed this into a list comprehension which creates a single list of these counts. You can check your work (or check Sage) by wrapping this list in sum() and hopefully getting \(5040\text{.}\)

Comment on the process of studying these questions first without any computational aid, and then again with Sage. For which values of \(n\) do you think Sage would be too slow and your mind quicker?