Showing posts with label number theory. Show all posts
Showing posts with label number theory. Show all posts

Sunday, June 23, 2019

pari operation time - Miller Rabin

Setting 1 in the call to ispseudoprime() in Pari/GP will get you a strong pseudoprime test (Miller-Rabin)

Pseudoprime tests are more practical first attempts when dealing with huge inputs ( In this example the number has 632202 decimal digits )

How long did the operation take? ## shows 13 hours 58 minutes




Link and further reading:


Thursday, June 27, 2013

Power of negative number - pari gp

Do use parentheses () to wrap your negative where necessary.






Because exponentiation has priority over +/- you should wrap your -1 in parentheses (), or, if just squaring, use the sqr() function.

The priority of operators in Pari/GP is detailed in Section 2.4 of the User Guide and titled "2.4 GP Operators"

Wednesday, August 31, 2011

Counter examples as Mnemonics - Remainders

When refreshing my memory about a Mathematical subject - I find counter examples can be a useful way of getting active. Here is an example about mod() / Congruences.

Working mod 4 with two numbers a=5 and b=7

...and writing in computing function form we say...

mod(a,4) = 1

  and

mod(b,4) = 3

Now apply a scaling (k) to both numbers ... say ... scaling by 11

mod(ka,4) = 3                       (ka is 55)

  and

mod(kb,4) = 1                       (kb is 77)


And what we observe is that the results seem to have exchanged places :)

This counter example is a good reminder that applying the same scaling to two different numbers does not always preserve the mod result.

There is much theory to access regarding congruences / modulo, and counter examples like this, can be a good way of stimulating a refresher of that theory.