On Oct 5, 2010, at 11:37 AM, Mateusz Paprocki <matt...@gmail.com> wrote:

Hi,

On Tue, Oct 05, 2010 at 10:16:01AM -0700, Ondrej Certik wrote:
On Tue, Oct 5, 2010 at 9:57 AM, Scott <spectre...@gmail.com> wrote:
Hello everyone!

I'm trying to do an integration of a large polynomial.  Though it is
large, it should be a pretty simple integration (simple/linear terms
if it is fully expanded).  I've run this exact polynomial through
maxima and it computes the output extremely quick (and evern longer
polynomial).  But when I use sympy (which I prefer to maxima), the
program runs for 30-45 min before it runs out of memory and I get a
memory error (4 GB of ram).

I also tried to through in a few (or many) "sympy.cache.clear_cache ()"
statements in hopes that it would help, but it doesn't.  I tried
printing some statements throughout the operations to see where it got
stuck.  It gets stuck on the first integration and the order of
integration (r, s, w) doesn't change the results.  So I get the
message "Point 2", but never see "Point 3" before it crashes (see code
below).

Let's keep improving this gist.

http://gist.github.com/611924

As a first step, let's agree on the polynomial. If you run this gist, you get:


Start
Point 1
expand
<class 'sympy.core.mul.Mul'>


so the polynomial is actually not a polynomial. How did you get this
"polynomial"? Can you rewrite it, so that you get an instance of
Add()? I tried to expand it, but it took forever.

After you have an instance of Add() (which every  polynomial should
be, right?), then we'll see how to integrate it. I am sure it will be
fast, if not, you can help it by integrating term by term by hand,
just like you did for chopping off the terms.


To transform this expression into a polynomial you will have to use
poly() function, which does expand()'s job but on polynomial level.

Applying poly() to LargePoly took about a minute on my laptop, giving
a polynomial with ~56k terms and of max norm 0.01171875. Integrating
(indefinite) is lighting fast compared to polynomial construction.

Example:

f = poly(LargePoly)

f.integrate(r)
f.integrate(s)
f.integrate(w)

Poly.integrate() does only indefinite integration, so definite integrals
you will have to obtain manually.

Note that poly() !== Poly().

Is there a specific reason for this, other than it hasn't been implemented yet?

Aaron Meurer


Ondrej

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sympy?hl=en .


--
Mateusz


--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to