Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FactorInteger - MathKernel crashes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73462] Re: FactorInteger - MathKernel crashes
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Sat, 17 Feb 2007 05:04:47 -0500 (EST)
  • References: <er3hhj$fee$1@smc.vnet.net>

The same holds true for version 5.2.

Let now

a3 = 13^24 + 5^37 * # &;

Then the following commands exhibits Mathematica normal behavior

In[44]:=
TableForm[({#1, Times@@ MapThread[HoldForm[#1^#2] & ,
Transpose[FactorInteger[a3[#1]]]]} & ) /@ Range[40], TableHeadings ->
{None, {"superscript", "factoring"}}, TableAlignments -> Center]

In[45]:=
TableForm[({#1, Times@@ MapThread[HoldForm[#1^#2] & ,
Transpose[FactorInteger[a3[#1]]]]} & ) /@ Range[42, 100],
TableHeadings -> {None, {"superscript", "factoring"}}, TableAlignments
-> Center]

In[46]:=
TableForm[({#1, Times@@ MapThread[HoldForm[#1^#2] & ,
Transpose[FactorInteger[a3[#1]]]]} & ) /@ Range[100, 1000],
TableHeadings -> {None, {"superscript", "factoring"}}, TableAlignments
-> Center]

I=2Ee. Mathematica (at least for superscript up to 1000!) crashes ONLY
for superscript equal to 41!

In[50]:=
({#1, a3[#1], Times@@ MapThread[HoldForm[#1^#2] & ,
Transpose[FactorInteger[a3[#1]]]]} & )[41]
(*Kernel crashes*)

Even the following setting does not change the situation

In[1]:=
a3[41] // FactorInteger[#, FactorComplete -> False] &
(*Kernel again crashes*)

Searching more I consult to the following link of WRI

http://support.wolfram.com/mathematica/kernel/Symbols/System/FactorInteger.=
html

In this link in case you don't know you can find additional
documentation for many Built-In symbols
not encountered anywhere else!

In the Notes for FactorInteger we read among many interesting things
(BTW may be the following link
is also interesting for you

http://support.wolfram.com/mathematica/mathematics/numerics/factorintegerme=
thods.html
)

"=2E..In Mathematica Version 3.0 there is an error in FactorInteger that
can cause the kernel to crash if the multiplicity of one of the
factors is greater than 2^16. This problem will be corrected for the
next version of Mathematica. The solution to this problem is to
temporarily create an expression (such as the result of Table[p,
{2^16}] that includes at least 2^16 copies of the repeated factor..."

So I guess that the problem for a3[41] (i.e. 13^24 + 5^37 * 41) is
that one of the factors is too big (bigger
than what? Somebody with deeper knowledge than me may tell).

With a little-not so clever I must admit!-programming one can factor
(at last!) a3[41]

First let figure out the factors of a3[41]

In[45]:=
Cases[({#1, 3525943392189575133132923486/#1} & ) /@
Prime[Range[100000]], {x_, _Integer} /; x > 2]
PrimeQ /@ %
Cases[({#1, %%[[1,2]]/#1} & ) /@ Prime[Range[100000]], {x_, _Integer}]
PrimeQ /@ %

Out[45]=
{{116371, 30299158657995335033066}}
Out[46]=
{{True, False}}
Out[47]=
{{2, 15149579328997667516533}}
Out[48]=
{{True, True}}

So the factors are 2, 116371, 15149579328997667516533.

Indeed

In[58]:=
2*116371*15149579328997667516533 == a3[41]

Out[58]=
True


I guess that the problem of crashing exists due to the factor
15149579328997667516533

In[61]:=
Length[IntegerDigits[15149579328997667516533]]
Out[61]=
23

Considering also the case of a3[39]

In[62]:=
({#1, a3[#1], Times @@ MapThread[HoldForm[#1^#2] & ,
Transpose[FactorInteger[a3[#1]]]]} & )[39]
Out[62]=
{39, 3380424239905906615066517236,
HoldForm[2^2]*HoldForm[7^2]*HoldForm[13^1]*HoldForm[602773^1]*HoldForm[2200=
989612048051709^1]}

In[64]:=
Length[IntegerDigits[2200989612048051709]]
Out[64]=
19

I guess (again!) that the problem may be encountered if one factor has
more than 20 integer digits!

I am sure next (or future in general...) edition of Mathematica will
not face this problem.

May be some of the Gurus around the this beautiful forum will provide
you with deeper
insight/algorithm/programming tactics!

And now here comes the question:

Looking again in above Notes for FactorInteger there is mentioned one
method in order
to solve the problem of crashing (at least for version 3.0).
Does anybody understand this method? I was not able to figure out it
meaning!


Best Regards
Dimitris

P=2ES. Now I learn something!












=CF/=C7 Costa Bravo =DD=E3=F1=E1=F8=E5:
> Hello,
>
> a1 = 2^4 + 7^24 * 719^2;
> a2 = 2^20 * 29^2 + 13^23;
> a3 = 13^24 + 5^37 * 41 ;
>
> MathKernel crashes, since I use
>
> FactorInteger[a1] or
> FactorInteger[a2] or
> FactorInteger[a3]
>
> Why ??
>
> If argument of FactorInteger is k*a1 or k*a2 or k*a3 (k = 2,3,4,......)
> MathKernel also crashes
>
> $Version
> 5.0 for Microsoft Windows
>
> Regards,
>   Costa



  • Prev by Date: Re: Numerical Convolution Problem, different results by
  • Next by Date: Automatic Notebook Evaluation
  • Previous by thread: Re: FactorInteger - MathKernel crashes
  • Next by thread: cellform to console form