开发者

How to avoid numeric exception : overflow in Maple 14?

开发者 https://www.devze.com 2023-04-08 16:03 出处:网络
Maple 14 has isprime command which testing whether number is prime or not. It\'s allowed to write expressions as input data so we may write the next command :

Maple 14 has isprime command which testing whether number is prime or not. It's allowed to write expressions as input data so we may write the next command :

isprime(2^(3^43-5)-1);

but I get the following error when trying to run a test :

Error, numeric exception: overflow

So my question is how t开发者_高级运维o avoid this overflow error ? Should I change default stack size and if it's so how to do that on win 7 ultimate ?


Since 3^43-5 is composite, then so is 2^(3^43-5)-1. See the wikipedia page on Mersenne primes. And you can get this result quickly in Maple. So if that's all you wanted, then you're done.

> isprime( 3^43-5 );
                         false

Now, suppose that you had a prime p of comparable size to 3^43. Let's say, the very next prime higher than that.

nextprime( 3^43-5 );
                 328256967394537077679

numtheory[mersenne]( nextprime( 3^43-5 ) );
                          FAIL

Ok, so that's too unfortunate.

Try applying isprime to 2^(10^6+3)-1. (Due to normal evaluation rules of maple procedures, isprime gets the expanded argument, so has no chance to see the special form and do the cheaper test against only 10^6+3. That's what numtheory[mersenne] is for.) You'll wait a while. Now imagine how long it would take isprime to handle a number about 10^11 times as large, which is about what you'd have if you used 2^nextprime(3^43-5)-1.

0

精彩评论

暂无评论...
验证码 换一张
取 消