Comment #7 on issue 2032 by asmeurer: Ability to work with K[x, 1/x] in
Polys
http://code.google.com/p/sympy/issues/detail?id=2032
For apart(), this is what I suggested in comment 2 (and is actually my
current workaround).
After some further thinking, I realized that deciding it for K[x, 1/x] is
trivial. Let f be an element of K(x) and write f as a/d with a, d in K[x],
gcd(a, d) = 1. Then f is in K[x, 1/x] if and only if d has only one term,
i.e., it is a monomial. You can prove this as an exercise. So I think the
following should solve my problem in full generality:
pa, pd = cancel(p.as_basic()).as_numer_denom()
pa, pd = Poly(pa, t, Poly(pd, t)
assert pd.is_monomial
d = pd.degree(t)
t_part = pa.slice(0, d + 1) # requires polys11
1t_part = pa - t_part
t_part = t_part.to_field().quo(pd)
# Compute the negative degree parts. Also requires polys11.
1t_part = Poly.from_list(reversed(1t_part.rep.rep), *1t_part.gens,
domain=1t_part.domain)
1t_part.replace(t, z) # z will be 1/t
ans = t_part.as_poly(t, z) + 1t_part.as_poly(t, z)
I hope this is correct. It could probably be cleverer. I think the
generalization to 1/a, if a is a Poly, is that the denominator has to be an
exact power of a times an exact power of t (but I wouldn't trust it, unless
you can prove it).
But Poly could (should) be smart enough to do this automatically using just
p.as_poly(t, 1/t). Actually, it seems to me that Poly should not pretend
that it can handle K[x, 1/x] unless it really can. For example:
In [8]: Poly(x**2 + x + 1, x, 1/x).quo(Poly(x**2, x, 1/x))
ExactQuotientFailed: x**2 does not divide 1 + x + x**2
I think 1/x type generators should not be allowed in Poly, since it gives
the impression that Poly can work with such expressions, when really it
can't.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" 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-issues?hl=en.