# # Chapter 17. Overview of Other Packages # # # # MAPLE SESSION 1 # > ?index[packages] # # 17.1 Finite fields # # # # MAPLE SESSION 2 # > 13 + 15 mod 17; > 13 - 15 mod 17; > 13/15 mod 17; > 13^(-1) mod 17; # # # MAPLE SESSION 3 # > P := x^4+3*x+1; > factor(P); > Factor(P) mod 43; # # # MAPLE SESSION 4 # > alias(alpha=RootOf(y^2+1)): > Normal(1/(1+alpha)) mod 5; # # # MAPLE SESSION 5 # > Factor(x^3+x+1) mod 2; # # # MAPLE SESSION 6 # > G8 := GF(2,3,alpha^3+alpha+1); # # # MAPLE SESSION 7 # > seq(G8[input](k),k=1..8); # # # MAPLE SESSION 8 # > a := G8[ConvertIn](1+alpha); > b := G8[ConvertIn](alpha^2); # # # MAPLE SESSION 9 # > G8[`^`](a,4); > G8[`/`](a,b); > G8[`*`](a,b); # # 17.2 Polynomials # # # # MAPLE SESSION 10 # > p:= x^4-4*x^2*y^2+4*y^4-6*x^2-12*y^2+9; > factor(p); > factor(p,sqrt(2)); > factor(p,sqrt(2),sqrt(3)); # # # MAPLE SESSION 11 # > beta := RootOf(Z^3+Z+1); > Q := x^6-2*x^4-x^3+2*x^2-1; > factor(Q,beta); # # # MAPLE SESSION 12 # > factor(Q,complex); # # # MAPLE SESSION 13 # > c := 0.3178372451957822447: > p := polytools[minpoly](c,4); > r := solve(p); > map(evalf,[r]); # # # MAPLE SESSION 14 # > P := 1 + x^2 + x^4; > polytools[split](P,x); # # 17.3 Group theory # # # # MAPLE SESSION 15 # > sigma := [3,4,6,2,5,1]; # # # MAPLE SESSION 16 # > dcp := convert(sigma,'disjcyc'); # # # MAPLE SESSION 17 # > convert(dcp,'permlist',6); # # # MAPLE SESSION 18 # > with(group): > G:=permgroup(4,{sigma=[[1,2,3,4]],tau=[[1,3],[2,4]]}); # # # MAPLE SESSION 19 # > grouporder(G); # # # MAPLE SESSION 20 # > elements(G); # # # MAPLE SESSION 21 # > with(group): > G := grelgroup(a,b,[a,a,a,a,a],[b,b],[a,b,a,1/b]); > grouporder(G); # # # MAPLE SESSION 22 # > p:= 2*(x^2+6*x-3)^3-27*(x+1)^3*(x^2-1); > galois(p); # # 17.4 Combinatorics # 17.4.1 The combinat package # # # # MAPLE SESSION 23 # > with(combinat): > T := cartprod([{1,2,3},{a,b},{A,B}]); # # # MAPLE SESSION 24 # > with(combinat): > C := {}: > T := cartprod([1,2,3,a,b,A,B]): > while not T[finished] do > C := C union T[nextvalue](): > xend do: > C; # # # MAPLE SESSION 25 # > with(combinat): > permute(4,2); # # # MAPLE SESSION 26 # > permute(4); > permute([a,b,c,d],3); > permute([a,a,c,d],3); # # # MAPLE SESSION 27 # > randperm([a,b,c,d]); # # # MAPLE SESSION 28 # > numbperm(12,5); > 12!/7!; # # # MAPLE SESSION 29 # > with(combinat): > choose(4,2); # # # MAPLE SESSION 30 # > choose([a,b,c,d,e,f],3); > choose([a,a,c,d,d,d],3); # # # MAPLE SESSION 31 # > with(combinat): > numbcomb(12,5); > 12!/5!/7!; > randcomb(12,5); > randcomb([a,b,c,d,e],3); # # # MAPLE SESSION 32 # > with(combinat): > P:=partition(6); > nops(P); # # # MAPLE SESSION 33 # > P := sum(numbpart(n)*q^ n,n=0..20); > series(1/P,q,21); # # # MAPLE SESSION 34 # > p:= [1,1,1,3,5,5,12,21,21]: > conjpart(p); # # # MAPLE SESSION 35 # > with(combinat): > composition(6,3); > nops(%); # # # MAPLE SESSION 36 # > numbcomp(6,3); # # # MAPLE SESSION 37 # > with(combinat): > powerset(4); > nops(%); # # # MAPLE SESSION 38 # > PS := subsets({a,b,c,d}); > while not PS[finished] do > PS[nextvalue](); > xend do; # # # MAPLE SESSION 39 # > with(combinat): > for j from 1 to 6 do > inttovec(j,3); > xend do; # # # MAPLE SESSION 40 # > with(combinat): > lambda := [1,1,3]: > rho := [1,1,1,1,1]: > Chi(lambda,rho); # # # MAPLE SESSION 41 # > with(combinat): > character(5); # # # MAPLE SESSION 42 # > with(combinat): > g := graycode(4); > printf(cat(` %.4d`$16,`\n`), op(map(convert, g, binary))); # # # MAPLE SESSION 43 # > with(combinat): > multinomial(12,3,4,5); > 12!/3!/4!/5!; # # 17.4.2 The networks package # # # # MAPLE SESSION 44 # > with(networks): > G:=new(): > addvertex({A,B,C,D,E,F},G); # # # MAPLE SESSION 45 # > addedge([{A,B},{B,C},{D,F},{E,F},{A,D},{C,E},{A,C}],G); # # # MAPLE SESSION 46 # > draw(G); # # # MAPLE SESSION 47 # > show(G); # # # MAPLE SESSION 48 # > ends(e1,G); # # # MAPLE SESSION 49 # > vertices(G); > ends(G); # # # MAPLE SESSION 50 # > H := duplicate(G): # # # MAPLE SESSION 51 # > delete(A,G): > draw(G); > delete(e1,H): > draw(H); # # # MAPLE SESSION 52 # > with(networks): > G:=new(): > addvertex({A,B,C,D},G): > addedge([[A,B],[B,A],[B,C],[C,D]],G); # # # MAPLE SESSION 53 # > head(e4,G); > tail(e4,G); # # # MAPLE SESSION 54 # > with(networks): > G := new(): > addvertex({A,B,C,D,E},G): > addedge([[A,B],[A,C],[A,D],[B,C],[B,E],[C,E],[D,E]], > names=[AB,AC,AD,BC,BE,CE,DE], > weights=[7,3,10,5,6,4,12],G); # # # MAPLE SESSION 55 # > eweight(G); # # # MAPLE SESSION 56 # > flow(G,A,E); # # # MAPLE SESSION 57 # > flow(G,A,E,sateds): > sateds; # # # MAPLE SESSION 58 # > with(networks): > G := new(): > addvertex({A,B,C},weights=[0,1,2],G); > addedge([[A,B],[B,C],[A,C]],G); > vweight(G); # # 17.4.3 The combstruct package # 17.5 Number theory # 17.5.1 The numtheory package # # # # MAPLE SESSION 59 # > n := 144; > ifactor(n); # # # MAPLE SESSION 60 # > with(numtheory): > n := 144; > divs := divisors(n); > factorset(n); > tau(n); > nops(divs); # # # MAPLE SESSION 61 # > with(numtheory): > factorEQ(30,-7); # # # MAPLE SESSION 62 # > with(numtheory): > nthpow(23152500); # # # MAPLE SESSION 63 # > with(numtheory): > p := mersenne([10]); > ifactor(p+1); # # # MAPLE SESSION 64 # > with(numtheory): > L := [seq([n,pi(n)/(n/log(n))],n=2..1000)]: > plot(L, style=point,labels=[n," "]); # # # MAPLE SESSION 65 # > with(numtheory): > safeprime(100); # # # MAPLE SESSION 66 # > with(numtheory): > g := primroot(17); > [seq(modp(g^ k,17),k=1..16)]; > sort(%); # # # MAPLE SESSION 67 # > with(numtheory): > order(2,17); > modp(2^8,17); # # # MAPLE SESSION 68 # > with(numtheory): > g := primroot(47); > d := index(6,5,47); > modp(g^ d,47); # # # MAPLE SESSION 69 # > with(numtheory): > mroot(2,5,13); > modp(6^5,13); # # # MAPLE SESSION 70 # > with(numtheory): > rootsunity(7,43); > map(`^`,[%],7); > map(modp,%,43); # # # MAPLE SESSION 71 # > with(numtheory): > legendre(15,23); > msqrt(15,23); # # # MAPLE SESSION 72 # > with(numtheory): > legendre(-1,41); > imagunit(41); > modp(%^2,41); # # # MAPLE SESSION 73 # > with(numtheory): > mcombine(4,3,5,4); # # # MAPLE SESSION 74 # > with(numtheory): > cfrac(exp(1),6); # # # MAPLE SESSION 75 # > with(numtheory): > cfrac(exp(1),30,'quotients'); # # # MAPLE SESSION 76 # > with(numtheory): > y := product( 1-q^(5*n-1))*(1-q^(5*n-4))/(1-q^(5*n-2)) > /(1-q^(5*n-3)),n=1..10): > cfrac(y,q,6); # # 17.5.2 The GaussInt package # 17.5.3 $p$-adic numbers # # # # MAPLE SESSION 77 # > with(padic): > r := 1705725; > s := 5561328861; > ifactor(r); > ifactor(s); > ordp(r,3); > ordp(s,3); > x:=r/s; > ordp(x,3); # # # MAPLE SESSION 78 # > valuep(x,3); # # # MAPLE SESSION 79 # > x; > evalp(x,3); # # # MAPLE SESSION 80 # > evalp(x,3,20); # # # MAPLE SESSION 81 # > with(padic): > px := p_adic(3,-4,[1,2,2,1,2,1,2,2,1,0]); > evalp(px,3); # # # MAPLE SESSION 82 # > with(padic): > z := sqrtp(10,3); > evalp(z^2,3); > sqrtp(2,3); # # # MAPLE SESSION 83 # > ?padic,function # # 17.6 Numerical approximation # # # # MAPLE SESSION 84 # > with(numapprox): > f := exp(x): > padf := pade(f,x,[3,3]); > taylor(f-padf,x,10);