#Nathan Fox #Homework 6 #I give permission for this file to be posted online ##Read old files read(`C7.txt`): #Help procedure Help:=proc() : print(` NaiveMUL(a,n) , CheckNaiveMul(K) , HalfToPower(n) `): print(` MUL(x,y) , CheckNaiveMulEquals(K) , CheckHalfTwo(n) `): end: ##Problem 1 #NaiveMUL(a,n): inputs a surreal number a, a usual pos. #integer n, and outputs a+a+ ...+a (repeated n times). NaiveMUL:=proc(a,n): if n=1 then return a: else return ADD(a, NaiveMul(a, n-1)): fi: end: ##Problem 2 #CheckNaiveMul(K): checks that NaiveMUL(SN(m),n) equals #(in Conway's sense) SN(m*n) for all m,n from 1 to K. CheckNaiveMul:=proc(K) local i,j: for i from 1 to K do for j from 1 to K do if not evalb(EQ(NaiveMUL(SN(i),j),SN(i*j))) then return false: fi: od: od: return true: end: #CheckNaiveMulEquals(K): checks that NaiveMUL(SN(m),n) equals #(NOT ONLY in Conway's sense) SN(m*n) for all m,n from 1 to K. CheckNaiveMulEquals:=proc(K) local i,j: for i from 1 to K do for j from 1 to K do if not evalb(NaiveMUL(SN(i),j)=SN(i*j)) then return false: fi: od: od: return true: end: #Are they equal in the usual sense? (say for K=10) #They are for K=10 ##Problem 3 #HalfToPower(n): inputs a positive integer n and outputs #the surreal representation of (1/2)^n. HalfToPower:=proc(n): if n=0 then return SN(1): else return [{SN(0)},{HalfToPower(n-1)}]: fi: end: ##Problem 4 #By comining HalfToPower(n) and NaiveMUL(a,n) check that #2^n * (1/2)^n =1 #CheckHalfTwo(n): procedure that tests this CheckHalfTwo:=proc(n): evalb(EQ(SN(1),NaiveMUL(HalfToPower(n),2^n))): end: #Everything I tried returns true ##Problem 5 #MUL(x,y): implements the definition of xy on page 5 of ONAG. MUL:=proc(x,y) local xL, xR, yL, yR: option remember: [ { seq(seq( ADD(MUL(xL,y), ADD(MUL(x,yL), Minus(MUL(xL,yL)))), xL in x[1]), yL in y[1]), seq(seq( ADD(MUL(xR,y), ADD(MUL(x,yR), Minus(MUL(xR,yR)))), xR in x[2]), yR in y[2])}, { seq(seq( ADD(MUL(xL,y), ADD(MUL(x,yR), Minus(MUL(xL,yR)))), xL in x[1]), yR in y[2]), seq(seq( ADD(MUL(xR,y), ADD(MUL(x,yL), Minus(MUL(xR,yL)))), xR in x[2]), yL in y[1])} ]: end: #Check that #MUL(SN(2),SN(2)) #equals (in Conway's sense) SN(4). #Command: evalb(EQ(MUL(SN(2),SN(2)), SN(4))): #How long did it take your computer? #This was very quick #Check that #MUL(SN(3),SN(4)) #equals (in Conway's sense) SN(12). #Command: evalb(EQ(MUL(SN(3),SN(4)), SN(12))): #How long did it take your computer? #Did not finish after 2 hours