> algorithms tend to do things like change the modulus of
> a number from time to time. Hensel lifting and the
> Chinese Remainder Algorithm do this. If you treat numbers
> as having an immutable modulus, this becomes clumsy.
A given modular number has an immutable modulus, just as a given
bigfloat has an immutable precision. But you can create a new number
with a different modulus from it, something like this:
q: new_modular_integer(2,7) => 2[mod 7]
q^5 => -3[mod 7]
q^(1/2) => 3[mod 7] -- arbitrary choice, I guess
q^(1/3) => 3[mod 7]^(1/3) -- no such root, so keep symbolic
(perhaps give error as option)
q: new_modular_integer(q,17) => 2[mod 17]
q^5 => -2[mod 17]
q^(1/2) => -2[mod 17]
q^(1/3) => 2[mod 17]
q: new_modular_integer(q,2) => 0[mod 2]
If you're thinking in terms of variable types (as opposed to object
types), as you know, Maxima doesn't normally work that way. That may be
a useful thing to add at some point, but....
-s
PS Sorry for the quibble, but I think it's worth pointing out that
almost all objects in Maxima are immutable (except for lists and
matrices).