Ray Toy:
> I think it would be better to return 'PROBABLY-PRIME
Addendum to my last note... and ignoring my warning to listen to real
users....
After thinking it over, I think Ray's idea has possibilities, though it
might be more Maxima-like would be to return a noun-form (but Maxima's
handling of noun-forms like this is not ideal).
For direct interactive use, returning something other than True/False
would be fine, though beginning users deserve some sort of
explanation/warning.
For programmatic use, it also has its points. If primep is used in a
conditional, e.g.
if primep(n) then ...
if mod(n,17)=3 or primep(n^2-2) then ...
then it will give an error if primep is neither true nor false (since
unlike Lisp, Maxima only accepts True and False as booleans). So it is
fail-safe (though annoying if the probabilistic test is good enough).
But the user can also handle the case explicitly:
if primep(n)=true then... (if proven prime)
if primep(n)#false then... (if probably prime)
if primep(n)#true then ... (if possibly composite)
if primep(n)=false then ... (if proven composite)
About the possible noun forms, I thought about this a little and came up
with a (too-)cute design. For example, as a verb,
primep(2342342342342342341,[miller_rabin([2,3,5,7,11,13,17,23,29],
test_divisor(234234349)) tests primality with Miller-Rabin test bases
2,...29 and with test divisors up to 234234349. As a noun, it means
that those tests have been performed and were inconclusive. This is is
a typical baroque hacker's solution, but I doubt any real users want it,
and it introduces a whole bunch of new conventions to Maxima. So my
conclusion is Keep It Simple; return noun-form 'primep(xxx) and give a
warning message (shouldn't we have a generic warning_level switch?).
-s