On Nov 27, 2007 11:11 PM, kent-and <[EMAIL PROTECTED]> wrote:
>
>
> > So you want:
> >
> > In [4]: f = x+y
> >
> > In [5]: g = x+z
> >
> > In [6]: f*g
> > Out[6]: (x + y)*(x + z)
> >
> > In [7]: f+g
> > Out[7]: y + z + 2*x
> >
> > So [6] is ok, but you want [7] to be "x+y+x+z" instead? Is it because
> > of memory requirements (see that issue for more details)?
> >
> >
>
> Well something like this, let say
>
> f = pow(x+1, 12) + pow(x-1, 12)
>
> This is a very efficient representation of f in terms of the number of
> operations
> needed to evaluate f(x).  Once expanded it is not easy to go back to
> an
> efficient representation without knowing what f was.

But I think both ginac and SymPy work in this way already:

In [1]: (x+1)**12 + (x-1)**12
Out[1]:
       12          12
(1 + x)   + (1 - x)

In [2]: f = (x+1)**12 + (x-1)**12

In [3]: f
Out[3]:
       12          12
(1 + x)   + (1 - x)

In [4]: f.expand()
Out[4]:
       12        2        10        4        8         6
2 + 2*x   + 132*x  + 132*x   + 990*x  + 990*x  + 1848*x


SymPy's automatic evaluation works in a way to only simplify things,
that can be done in a very fast way. Expanding doesn't belong to that
categhory.

> BTW: I've tested the patch, great speed-up, great work!

Thanks! It will be committed and released soon.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to