I would like to know why Mod gives the correct result and PowerMod gives an incorrect result.
Mod[0^0,7]
PowerMod[0,0,7]
I would like to know why Mod gives the correct result and PowerMod gives an incorrect result.
Mod[0^0,7]
PowerMod[0,0,7]
Maybe it has something to do with the following in the help:
For positive b, PowerMod[a,b,m] gives the same result as Mod[a^b, m]
but is much more efficient.
0 is not positive:
Positive[0]
False
Yes, 0 is not positive, but does that explain the result of PowerMod[0, 0, 7]?
The reason is that 0 and 7 are congruent modulo 7, so in the context of the ring Z/7Z, 0^0 can be thought of as the same as 7^0. Thus we obtain the same result as PowerMod[7, 0, 7].
With Mod the situation is different, since 0^0 evaluates to Indeterminate first, so we are asking for Mod[Indeterminate, 7].
I think that is indeed the real reason, i was trying to point out that 0 is one of those `fringe’ cases where things might be different from what you expect…