A much reduced testcase: x,y = [Symbol(_) for _ in ['x','y']] foo = 1/(x+y)-Rational(1,2)*x**2 print(foo.apart(x))
This prints: 1/(x + y) If the Rational has an integral value, everything looks ok: foo = 1/(x+y)-Rational(6)*x**2 print(foo.apart(x)) Output: -6*x**2 + 1/(x + y) On 10 March 2015 at 15:57, Francesco Biscani <[email protected]> wrote: > Hello list, > > I feel a bit embarrassed as probably I am doing something blatantly wrong, > but I cannot understand what is going here. Consider this snippet (copy > pasted from an Ipython notebook): > > """ > import sympy > sympy.init_printing() > from sympy import Symbol,sqrt,cos,sin,solve,Function,atan,apart,S > > # Some symbols > h,n,m,M,g,t,xi_s,eta_s = [Symbol(_) for _ in > ['h','n','m','M','g','t',r'\xi',r'\eta']] > pxi,peta = [Symbol(_) for _ in [r'p_\xi',r'p_\eta']] > > # A rational expression > foo = > 32*eta_s**8*g*m/(eta_s**2+xi_s**2)**3-64*eta_s**6*g*m/(eta_s**2+xi_s**2)**2-23*g/2*eta_s**2*m-7*g/2*xi_s**2*m+(320*eta_s**4*g*m**2+peta**2+pxi**2)/(8*m*(eta_s**2+xi_s**2)) > """ > > Now if I do "foo_apart(xi_s)", it seems like there are two parts of the > expression that disappear. (specifically, > -23*g/2*eta_s**2*m-7*g/2*xi_s**2*m is not there any more). Indeed, if I do: > > """ > foo.apart(xi_s).expand() == foo.expand() > """ > > This returns False. > > My brain is a bit fried at the moment :) So what am I overlooking here? > > Cheers, > > Francesco. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHExjCug%2B%2B_%3DsnWhoA6uTykrV0STWtTO_6B%3DBYDbBz1mY1HKuA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
