#!/usr/local/bin/maple # -*- maplev -*- # Nathaniel Shar # HW 6 # Experimental Mathematics # It is okay to link to this assignment on the course webpage. Help := proc(): print(`ConWay1(L,R, i), IsCyclic(G), ConWay(L, R, checkDAG:=0), ClassifyGame(G), Sig(L, R), RandGame(n,k), AveSig(n,k,K)`): end: ############# # Problem 1 # ############# # In order to save computational time, we'll assume that the game # satisfies the ending condition. ConWay1 := proc(L,R, i): return [map[3](ConWay1, L, R, L[i]), map[3](ConWay1, L, R, R[i])]: end: ############# # Problem 2 # ############# # From c2.txt: IsCyclic:=proc(G) local i,M1,M: option remember: M:=AM(G): M1:=M: #Soon-to-be PhD candidate #Jacob Baron thinks that it safer to do nops(G)+1 for i from 1 to nops(G)+1 do if trace(M1)>0 then RETURN(true): fi: M1:=evalm(M1*M): od: false: end: ### ConWay := proc(L, R, checkDAG:=0) local i: # This is a good place to check that the game ends, if desired, # since it is only done once. if checkDAG <> 0 then: if IsCyclic([seq(L[i] union R[i], i=1..nops(L))]) then: return FAIL: fi: fi: return [seq(ConWay1(L, R, i), i=1..nops(L))]: end: ############# # Problem 3 # ############# # Note: Adding strings does not appear to work in this version of maple. ClassifyGame := proc(G) local Lc, Rc, ltpw, rtpw: if G = [{}, {}] then: return zero: fi: Lc := map(ClassifyGame, G[1]): Rc := map(ClassifyGame, G[2]): if positive in Lc or zero in Lc then: ltpw := true: else: ltpw := false: fi: if negative in Rc or zero in Rc then: rtpw := true: else: rtpw := false: fi: if ltpw and rtpw then: return fuzzy: elif ltpw and not rtpw then: return positive: elif not ltpw and rtpw then: return negative: elif not ltpw and not rtpw then: return zero: fi: end: Sig := proc(L, R) local i: return convert(map(ClassifyGame, ConWay(L, R)), `+`): end: ############# # Problem 4 # ############# # From c2.txt: RandGame:=proc(n,k) local L,i,tomas,j: L:=[{}]: for i from 2 to n do tomas:={seq(rand(1..i-1)(),j=1..k)}: L:=[op(L), tomas]: od: L: end: AveSig := proc(n,k,K) local i: return add(Sig(RandGame(n,k), RandGame(n,k)), i=1..K)/K: end: # Here is one output: #1.55 zero + 4.77 fuzzy + 1.47 negative + 2.21 positive # Of course the distribution is approximately normal, by the central # limit theorem. So in that sense I do get the same results all the # time, more or less.