Hi,

On 16 June 2011 13:28, Aaron Meurer <[email protected]> wrote:

> This is related to
> http://code.google.com/p/sympy/issues/detail?id=2032.  The polys
> pretend that they can work in K[x, 1/x], but they actually do not
> implement things properly, which can lead to wrong results:
>
> In [3]: Poly(exp(-x))
> Out[3]: Poly(exp(-x), exp(-x), domain='ZZ')
>
> In [4]: Poly(exp(-x))*exp(x)
> Out[4]: Poly(exp(x)*exp(-x), exp(-x), domain='ZZ[exp(x)]')
>
> In [5]: Poly(exp(-x))*exp(x) - 1
> Out[5]: Poly(exp(x)*exp(-x) - 1, exp(-x), domain='ZZ[exp(x)]')
>
> In [6]: (Poly(exp(-x))*exp(x) - 1).is_zero
> Out[6]: False
>
> And I could go further, as an incorrect is_zero result can easily be
> exacerbated to larger wrong results, but you get the idea.
>

Result [6] is actually a valid result, because generators of polynomial
expressions are assumed to be algebraically independent, so in [6] you can
write (Poly(u)*v - 1).is_zero (which of course is False) as well. If you
want [6] to give True, then you would have to imply an algebraic relation
between exp(-x) and exp(x) (really u and v). A reasonable solution I see to
this problem is to implement LaurentPoly which would allow negative
exponents, which in turn would mean that exp(-x) and exp(x) would result in
the same generator, with exponent -1 and 1 respectively.
Another solution would be to add postprocessor to Poly, which would apply
known algebraic relations of generators, after performing the main
computation.


>
> Aaron Meurer
>
> On Thu, Jun 16, 2011 at 12:15 PM, Mateusz Paprocki <[email protected]>
> wrote:
> > Hi,
> >
> > On 16 June 2011 20:09, smichr <[email protected]> wrote:
> >>
> >> The exp(x)*exp(-x) term in the Poly should cancel, shouldn't it?
> >>    >>> Poly(exp(x) + exp(-x) - y)*exp(x)
> >>    Poly(-y*exp(x) + exp(-x)*exp(x) + exp(x)**2, y, exp(-x), exp(x),
> >>    domain='ZZ')
> >
> > Polynomials can't contain negative exponents, so exp(x) and exp(-x) =
> > 1/exp(x) are treated as two different generators.
> >
> >>
> >> --
> >> 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.
> >>
> >
> > Mateusz
> >
> > --
> > 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.
> >
>
> --
> 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.
>
>
Mateusz

-- 
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