{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

355f2001-assign-05-combinat

# 355f2001-assign-05-combinat - MLC Lab Visit More...

This preview shows pages 1–4. Sign up to view the full content.

MLC Lab Visit - More Combinatorics Mth 355 Fall 2001 Assignment 5 (at end). Due Oct 31. Mth 355 (a.k.a. Mth 399) Oct 23 2001 Maple 6 Bent E. Petersen Filename: 355f2001-assign-05-combinat.mws Maple has quite a bit of combinatorial support available in the combstruct and combinat packages. This Worksheet is a summary of some of the combinatorial computations you can do with Maple. At the end of the worksheet are a few problems which constitute Assignment 5. > restart; > with(combstruct); [ ] , , , , , , , , allstructs count draw finished gfeqns gfseries gfsolve iterstructs nextstruct > with(combinat); Warning, the protected name Chi has been redefined and unprotected Chi bell binomial cartprod character choose composition conjpart decodepart encodepart , , , , , , , , , , [ fibonacci firstpart graycode inttovec lastpart multinomial nextpart numbcomb numbcomp , , , , , , , , , numbpart numbperm partition permute powerset prevpart randcomb randpart randperm , , , , , , , , , stirling1 stirling2 subsets vectoint , , , ] Permutations The allstructs() function produces a list of all permutations of the specified objects. The function iterstructs() allows one to iterate over the list of objects which would be returned by allstructs(), without first returning the list. Here are the 2-permutations of [a,b,c,d] > allstructs(Permutation([a,b,c,d]),size=2); [ ] , , , , , , , , , , , [ ] , a b [ ] , a c [ ] , a d [ ] , b a [ ] , b c [ ] , b d [ ] , c a [ ] , c b [ ] , c d [ ] , d a [ ] , d b [ ] , d c If the argument provided is an integer n, rather than a list, it is treated as the list [1,...,n]. Thus > allstructs(Permutation(4),size=2); [ ] , , , , , , , , , , , [ ] , 1 2 [ ] , 1 3 [ ] , 1 4 [ ] , 2 1 [ ] , 2 3 [ ] , 2 4 [ ] , 3 1 [ ] , 3 2 [ ] , 3 4 [ ] , 4 1 [ ] , 4 2 [ ] , 4 3 To use an iterator instead is simple > iter1:=iterstructs(Permutation([a,b,c,d]),size=2):

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> while not finished(iter1) do > nextstruct(iter1); > od; [ ] , a b [ ] , b a [ ] , a c [ ] , c a [ ] , a d [ ] , d a [ ] , b c [ ] , c b [ ] , b d [ ] , d b [ ] , c d [ ] , d c Of course you will want to do something useful inside the do-loop. You can also do permutations with repeated objects. > allstructs(Permutation([a,b,c,c]),size=2); [ ] , , , , , , [ ] , a b [ ] , a c [ ] , b a [ ] , b c [ ] , c a [ ] , c b [ ] , c c A special keyword, allsizes, is used if you want all r-permutations for each size of r. > allstructs(Permutation([a,b,c]),size=allsizes); [ ] [ ] a [ ] b [ ] c [ ] , a b [ ] , a c [ ] , b a [ ] , b c [ ] , c a [ ] , c b [ ] , , a b c [ ] , , a c b [ ] , , b a c , , , , , , , , , , , , , [ [ ] , , b c a [ ] , , c a b [ ] , , c b a , , ] Note the 0-permutation, or empty permutation, is also returned. Be careful about that. The count() function returns a count of the number of structures of the given type, for example permutations. > count(Permutation([a,b,c]),size=allsizes); 16 > count(Permutation([a,b,c]),size=3); 6 The draw() function returns a randomly selected structure of the type specified, for example, a
permutation. > draw(Permutation([a,b,c,d]),size=3); [ ] , , d a c You can also use randperm() to obtain a random permutation. > randperm([a,b,c,d]); [ ] , , , a d b c Note you can not specify the size in randperm(). You can also use the permute() function to obtain permutations. > permute([a,b,c,d],2); [ ] , , , , , , , , , , , [ ] , a b [ ] , a c [ ] , a d [ ] , b a [ ] , b c [ ] , b d [ ] , c a [ ] , c b [ ] , c d [ ] , d a [ ] , d b [ ] , d c > permute([a,b,c]); [ ] , , , , , [ ] , , a b c [ ] , , a c b [ ] , , b a c [ ] , , b c a [ ] , , c a b [ ] , , c b a > permute([a,a,b],2); [ ] , , [ ] , a a [ ] , a b [ ] , b a Combinations Combinations work much the same as permutations.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 17

355f2001-assign-05-combinat - MLC Lab Visit More...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online