355f2001-assign-05-combinat

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

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

View Full Document Right Arrow Icon
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); [ ] ,,,,,,,,,,, [] , ab , ac , ad , ba , bc , bd , ca , cb , cd , da , db , dc 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); [ ] , 12 [ ] , 13 [ ] , 14 [ ] , 21 [ ] , 23 [ ] , 24 [ ] , 31 [ ] , 32 [ ] , 34 [ ] , 41 [ ] , 42 [ ] , 43 To use an iterator instead is simple > iter1:=iterstructs(Permutation([a,b,c,d]),size=2):
Background image of page 1

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

View Full DocumentRight Arrow Icon
> while not finished(iter1) do > nextstruct(iter1); > od; [] , ab , ba , ac , ca , ad , da , bc , cb , bd , db , cd , dc 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); ,,,,,, , , , , , , , cc 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 , , , , , , ,, abc acb bac , , , ,,,,,,, , , , [ bca cab cba ] 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
Background image of page 2
permutation. > draw(Permutation([a,b,c,d]),size=3); [] ,, dac You can also use randperm() to obtain a random permutation. > randperm([a,b,c,d]); ,,, adbc 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); [ ] ,,,,,,,,,,, , ab , ac , ad , ba , bc , bd , ca , cb , cd , da , db , dc > permute([a,b,c]); ,,,,, abc acb bac bca cab cba > permute([a,a,b],2); , aa , , Combinations Combinations work much the same as permutations. > allstructs(Combination([a,b,c,d]),size=2); , , , , , , If the argument provided is an integer n, rather than a list, it is treated as the set {1,. ..,n}. Thus > allstructs(Combination(4),size=2); {} , 12 { } , 13 { } , 14 { } , 23 { } , 24 { } , 34 Iterators works as they do for permutations.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/11/2012 for the course MTH 141, 142, taught by Professor Mcallister during the Spring '08 term at SUNY Empire State.

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 Right Arrow Icon
Ask a homework question - tutors are online