Some aids for writing procedures

Here are a few Maple commands that may be of use.

Setting printlevel to 10 will force Maple to print out intermediate data computed within a given procedure. Setting it to 20 will also printout data in procedures called by the given procedure.

> printlevel := 1;

printlevel := 1

> goodprimelist(10,50);

[11, 23, 47]

> printlevel := 20;

printlevel := 20

> goodprimelist(10,50);

{--> enter goodprimelist, args = 10, 50

plist := []

value remembered (in goodprimelist): isprime(10) -> false

value remembered (in goodprimelist): isprime(11) -> true

{--> enter goodprime, args = 11

pp := 5

bool := true

<-- exit goodprime (now in goodprimelist) = true}

plist := [11]

value remembered (in goodprimelist): isprime(12) -> false

value remembered (in goodprimelist): isprime(13) -> true

{--> enter goodprime, args = 13

pp := 6

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(14) -> false

value remembered (in goodprimelist): isprime(15) -> false

value remembered (in goodprimelist): isprime(16) -> false

value remembered (in goodprimelist): isprime(17) -> true

{--> enter goodprime, args = 17

pp := 8

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(18) -> false

value remembered (in goodprimelist): isprime(19) -> true

{--> enter goodprime, args = 19

pp := 9

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(20) -> false

value remembered (in goodprimelist): isprime(21) -> false

value remembered (in goodprimelist): isprime(22) -> false

value remembered (in goodprimelist): isprime(23) -> true

{--> enter goodprime, args = 23

pp := 11

bool := true

<-- exit goodprime (now in goodprimelist) = true}

plist := [11, 23]

value remembered (in goodprimelist): isprime(24) -> false

value remembered (in goodprimelist): isprime(25) -> false

value remembered (in goodprimelist): isprime(26) -> false

value remembered (in goodprimelist): isprime(27) -> false

value remembered (in goodprimelist): isprime(28) -> false

value remembered (in goodprimelist): isprime(29) -> true

{--> enter goodprime, args = 29

pp := 14

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(30) -> false

value remembered (in goodprimelist): isprime(31) -> true

{--> enter goodprime, args = 31

pp := 15

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(32) -> false

value remembered (in goodprimelist): isprime(33) -> false

value remembered (in goodprimelist): isprime(34) -> false

value remembered (in goodprimelist): isprime(35) -> false

value remembered (in goodprimelist): isprime(36) -> false

value remembered (in goodprimelist): isprime(37) -> true

{--> enter goodprime, args = 37

pp := 18

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(38) -> false

value remembered (in goodprimelist): isprime(39) -> false

value remembered (in goodprimelist): isprime(40) -> false

value remembered (in goodprimelist): isprime(41) -> true

{--> enter goodprime, args = 41

pp := 20

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(42) -> false

value remembered (in goodprimelist): isprime(43) -> true

{--> enter goodprime, args = 43

pp := 21

bool := false

<-- exit goodprime (now in goodprimelist) = false}

value remembered (in goodprimelist): isprime(44) -> false

value remembered (in goodprimelist): isprime(45) -> false

value remembered (in goodprimelist): isprime(46) -> false

value remembered (in goodprimelist): isprime(47) -> true

{--> enter goodprime, args = 47

pp := 23

bool := true

<-- exit goodprime (now in goodprimelist) = true}

plist := [11, 23, 47]

value remembered (in goodprimelist): isprime(48) -> false

value remembered (in goodprimelist): isprime(49) -> false

value remembered (in goodprimelist): isprime(50) -> false

<-- exit goodprimelist (now at top level) = [11, 23, 47]}

[11, 23, 47]

Another interesting thing is to look at the Maple code for some of the functions that you use.

The rather cryptic command sequence is to set verboseproc =2 and use print.

> printlevel := 1;

printlevel := 1

> interface(verboseproc=3);

>

> print(isprime);

proc (n) local btor, nr, p, r; options remember, sy...

> print(ifactor);

Finally the function showtime() allows will tell you how long a function takes to perform.

> showtime();

O1 := isprime((2^(2^11)+1));

false

time = 6.29, bytes = 22887974

O2 := isprime(2^(2^11)+ 7);

false

time = 2.68, bytes = 29854

O3 := isprime(2^(2^11) +2);

false

time = 0.00, bytes = 5454

O4 := off;