Re: Two starting programming questions re alternating groups and EulerPhi LCM numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg37917] Re: [mg37912] Two starting programming questions re alternating groups and EulerPhi LCM numbers
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Tue, 19 Nov 2002 20:58:19 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
1. The answers to your first question are all contained in the standard
package
<< DiscreteMath`Combinatorica`
Listing the elements of A5 could not be simpler:
In[2]:=
A5=AlternatingGroup[5];
In[3]:=
Length[%]
Out[3]=
60
First you need to define multiplication of permutations.
mult[x_?PermutationQ, y_?PermutationQ] :=
Permute[Permute[IdentityPermutation[5], x], y]
for example:
In[5]:=
mult[A5[[2]],A5[[3]]]
Out[5]=
{1,2,3,4,5}
you can check yourself that A5[[2]] and A5[[3]] are indeed inverses.
You can compute the order of each element using the following simple
code:
In[5]:=
ord[(p_)?PermutationQ] := Length[NestWhileList[mult[p, #1] & , p, #1 !=
IdentityPermutation[5] & ]]
You can map this onto the whole group to get the orders of all the
elements:
In[6]:=
ord /@ A5
Out[6]=
{1, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 2, 2, 2, 2, 3, 5, 5, 5, 3, 5, 5, 3,
5, 3, 5, 5, 2, 3, 3, 2, 5, 5, 2, 5, 5, 5, 3, 5, 3, 3, 2, 5, 2,
5, 5, 5, 2, 5, 3, 5, 3, 3, 2, 5, 2, 5, 5, 5, 2}
You can get the multiplication table with a single command:
MultiplicationTable[A5, mult] // TableForm
The elements in the table are described by their position in the list
representing A5.
2) The following simple code will do what you want:
relativePrimes[q_] := Select[Range[q], GCD[#1, q] == 1 &]
You can check it works:
In[10]:=
Length[relativePrimes[20]]==EulerPhi[20]
Out[10]=
True
Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/
On Tuesday, November 19, 2002, at 05:51 PM, Diana wrote:
> Mathematica junkies...
>
> I have ordered Mathematica Student, and am excited about starting to
> program with it.
>
> I was wondering if someone with experience could help me with two
> (easy?) programs to get started.
>
> Program 1:
>
> A. I want to first list the elements of A_5. These would be the even
> permutations of S_5, such as:
>
> (1, 2, 3, 4, 5)
> (1, 2, 4, 3 5), etc. There are 60 of these.
>
> B. Secondly, I want to figure out how to compute the order of each of
> the elements.
>
> C. Last, I want to create a Cayley table of 60 x 60 elements, i.e.,
> (1, 2, 3, 4, 5) * (1, 2, 4, 3, 5). This would be the answer you get to
> first permuting a 5-tuple by (1, 2, 3, 4, 5), and then permuting it by
> (1, 2, 4, 3, 5).
>
> I have done all of this with an Excel spreadsheet, and am not turning
> this in or getting credit for it. Just want to know how to do it.
>
> Program 2
>
> I understand that Mathematica has the EulerPhi function in it. Does
> anyone know how to get the program to list the elements which are less
> than and relatively prime to any given "n"?
>
> Thanks,
>
> Diana
>
>
>
>