3
$\begingroup$

The following is for Mathematica 8.0.4 running on Windows 7 laptop (6GB memory).

I have eight expressions that are unexpanded multivariate polynomials in 6 variables. They are huge expressions, so big that I cannot run Exponent[] to get the degrees in the variables. (After waiting for several minutes, I have to abort.)

Similarly, I abort any call to Expand[] after waiting a few minutes (or maybe an hour).

Then, I inspected the first "layer" of each expression and wrote a function that expands each part of the first layer and then combines the results. The function does Print[]s so that I know there is progress. For example, the first expression is the sum of three sub-expressions. The function calculates and expands the individual sub-expressions and then combines them.

Starting with the simplest expression, I ran the function. Each sub-expression had (order of magnitude) 500K terms. There was a lot of cancellation and the sum of the three sub-expressions ended up being about 500K terms. The polynomials have rational coefficients (actually integer) with the exception of a Sqrt[3]. I replaced Sqrt[3] with a 7th variable to make it rational. Then, I ran Factor[] on the results and got it down to 80K terms. Almost manageable, also note the Exponent[] call now worked.

I repeated this for four more expressions, each expression being more complicated than the previous. Each expression had lots of cancellation and then factored. So far, I have 5 out of the 8 expressions simplified. I had some sub-expressions with nearly 2M terms.

For the 6th expression, I am stuck. It is the sum of four sub-expressions. My function expanded the first two successfully (2.3M terms and 1.9M terms, respectively). It has been working on the third sub-expression for 2 days.

Trying to assess whether it was making progress, I have been looking at the "Windows Task Manager" to see how the "mathkernel.exe" process is doing. It barely using any CPU% but it is slowly accumulating CPU Time (maybe 30s in the last hour). It is doing something, because I see the memory changing. It is maxing out memory (goes up to approx 3.7GB, drops and rises again) and having some hard faults.

I also tried to use the "Evaluation->Kernel Status" menu command. This puts me into a cycle of getting the prompt "The kernel is not responding to a dynamic evaluation. You may either choose abort and restart the kernel or continue waiting". I finally chose Abort and this killed the kernel. It had accumulated about 8Hrs of CPU time over a few days.

Has anyone had success or knowledge about expanding huge expressions that simplify and factor? Maybe I can go another layer deeper and expand those sub-sub-expressions.

Update. I have made some tweaks to this evaluation. I finally got Mathematica to explicitly tell me that it ran out of memory. I think it had to have enough memory to finish the calculation. I got the message:

No more memory available. Mathematica kernel has shut down. Try quitting other applications and then retry.

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Jan 1 '15 at 16:36
  • 2
    $\begingroup$ Please explain how you obtained these gigantic expressions. It may be that performing simplifications earlier, as you construct the expressions, would work better. $\endgroup$ – bbgodfrey Jan 1 '15 at 16:39
  • $\begingroup$ Welcome! If possible, sharing code is often very useful in getting answers. $\endgroup$ – Yves Klett Jan 1 '15 at 16:40
  • $\begingroup$ The expressions come from the coefficients of the remainder of a PolynomialReduce[] function call. (So it is one way to see if one polynomial is a factor of another.) I have been looking for other opportunities to simplify and even other methods to attack the problem (e.g. GroebnerBasis). $\endgroup$ – Mike Griffis Jan 3 '15 at 12:51
  • 1
    $\begingroup$ @MikeGriffis You got my upvote for this question, because I think you have explained your problem very carefully, especially since it is your first post here. Nevertheless, do you think it would be possible to create a toy example which is similar to your real output. Something that users can take to see your problems live? Maybe a huge toy example can be generated from a very simple code... Otherwise, I'm afraid no one dares to guess any solution which is not tested. $\endgroup$ – halirutan Jan 3 '15 at 14:11
2
$\begingroup$

After reading the Mathematica tutorial on "Memory Management", I was enlightened. (I cannot believe that I missed that help.) I was able to carry out the calculations by being more careful and expanding only the expressions that were necessary to simplify a given expression. In this way, I only had in memory exactly what was necessary. And for my examples, I was able to expand (out to up to 8 million terms) and simplify and then actually factor it. At the end of the day, for my 8 expressions, I have expressions ranging from 80K to less than 1M terms.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.