{VERSION 3 0 "SGI MIPS UNIX" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 399 "Number system with base b eta. Let beta be some fixed positive integer > 1, and let [a.n,a.(n-1) ,....,a0] denote the integer a.n * beta^n +... + a.0 * beta^0 where ea ch a.i is an integer in the range 0 .. beta-1. The a.i are called digi ts. They are the usual digits 0..9 when beta=10, which is the common w ay humans represent numbers. They are 0 or 1 when beta=2, which is com mon inside the computer." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 " beta:=10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "L:=[1,2,3,4,5, 6,5,4,3,2,1,0];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 85 "list_to_ integer:=proc(L,beta)\n local i;\n add(L[-i]*beta^(i-1), i=1..nops (L))\nend;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "list_to_integ er(L,10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 274 "Computers can store lists of arbitrary (depending on the amount of memory) lenght. This w ay we can store integers with arbitrary many digits. In this way of de noting integers beta is called the base of the number system. If we ta ke beta=1000 then each entry stores 3 digits." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "beta:=1000;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "L:=[1,2,1,2,345,678];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "list_to_integer(L,beta);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 81 "Computers often store numbers internally with a base beta =2 or beta=a power of 2." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 " beta:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "L:=[1,1,1,0,0,0 ,0,1,1,1,1,1,0,0,1,0,1];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "list_to_integer(L,beta);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 140 "Let s write some procedures to add and multiply numbers represented in bas e beta, to get an idea how a computer could multiply large numbers." } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 361 "add_lists:=proc(L1,L2,bet a)\n local n,res,i,q,r;\n n:=nops(L1)-nops(L2);\n if n<0 then\n \+ RETURN( procname(L2,L1,beta) )\n elif n>0 then\n RETURN( procname(L1,[0$n,op(L2)],beta) )\n fi;\n n:=nops(L1);\n res:=NU LL;\n q:=0;\n for i from 1 to n do\n res := irem(q+L1[-i]+L2[ -i],beta,'q'),res\n od;\n if q>0 then res:=q,res fi;\n [res]\nen d;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "beta:=10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "L1, L2 := [7,2], [5,5];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "add_lists(L1,L2,beta);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "add_lists(%,L2,beta);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "add_lists(%,L2,beta);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "add_lists(L1,%,beta);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 164 "mult_lists:=proc(L1,L2,beta)\n lo cal i,j,res;\n res:=[0];\n for i from 1 to nops(L1) do\n res:=a dd_lists(res,[seq(j*L1[-i],j=L2),0$(i-1)],beta)\n od;\n res\nend;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "mult_lists([1,2,3,4],[2,3, 4],10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "1234*234;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "beta:=1000;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L1:=[seq(rand(0..beta-1)(),i=1..100 )]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L2:=[seq(rand(0..bet a-1)(),i=1..100)]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "time( ); mult_lists(L1,L2,beta); time();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "29" 0 }{VIEWOPTS 1 1 0 1 1 1803 }