# Matthew Russell # Experimental Math # Homework 7 # I give permission to post this read `public_html/em13/c7.txt`: ##################################################################################### # Recall that multiplication by an integer is repeated addition. # By using ADD, write a procedure # NaiveMUL(a,n) # that inputs a surreal number a, # a usual pos. integer n, # and outputs a+a+ ...+a (repeated n times). NaiveMUL:=proc(a,n) option remember: if n=1 then return a: fi: if n=2 then return ADD(a,a): fi: return ADD(NaiveMUL(a,n-1),a): end: ##################################################################################### # Write a procedure # CheckNaiveMul(K) # that checks that NaiveMUL(SN(m),n) # equals (in Conway's sense) SN(m*n) # for all m,n from 1 to K. # Are they equal in the usual sense? (say for K=10) CheckNaiveMul1:=proc(m,n) return EQ(SN(m*n),NaiveMUL(SN(m),n)): end: CheckNaiveMul:=proc(K) local m,n: for m from 1 to K do for n from 1 to K do if not CheckNaiveMul1(m,n) then return false: fi: od: od: return true: end: # Yes, checked for K=25 ##################################################################################### # By reading pages 7-9 of ONAG figure out a (recursive) definition of (1/2)^n for integer n. # Write a procedure # HalfToPower(n) # that inputs a positive integer n and outputs the surreal representation of (1/2)^n. HalfToPower:=proc(n) option remember: if n=1 then return [{SN(0)},{SN(1)}]: fi: return [{SN(0)},{HalfToPower(n-1)}]: end: ##################################################################################### # By combining HalfToPower(n) and NaiveMUL(a,n) check that # 2^n * (1/2)^n =1 HalfCheck:=proc(n) return EQ(NaiveMUL(HalfToPower(n),2^n),SN(1)): end: ##################################################################################### # Write a procedure # MUL(x,y) that implements the definition of xy on page 5 of ONAG. MUL:=proc(x,y) return [ { seq(MUL(xL,y),xL in x[1]) }, { } ]: #end: # Check that # MUL(SN(2),SN(2)) # equals (in Conway's sense) SN(4). # How long did it take your computer? Check22:=proc() t0:=time(): check:=EQ(MUL(SN(2),SN(2)),SN(4)): print(`This took `,time()-t0,` seconds`): return check: end: # Check that # MUL(SN(3),SN(4)) # equals (in Conway's sense) SN(12). # How long did it take your computer? Check34:=proc() t0:=time(): check:=EQ(MUL(SN(3),SN(4)),SN(12)): print(`This took `,time()-t0,` seconds`): return check: end: