Hi Kate, On Tue, Feb 22, 2011 at 9:03 AM, Kate <[email protected]> wrote: > Hello all, > > I discovered sympy recently, and am very impressed. It does almost > everything I need (and way more besides).
Excellent! > > I'm making a start on removing the auto-distribution of constants > (which is apparently an old issue, referred to at > http://code.google.com/p/sympy/issues/detail?id=1497 and > http://groups.google.com/group/sympy/browse_thread/thread/32bbf03c1bd922aa/a6557f077e3b2df1? > among other places). > > So far, I'm going through the failed tests, and fixing the trivial > ones (by trivial I mean that the expected behavior has changed, so > Rational(1,2)*(x+y) should return (x+y)/2, not x/2 + y/2), and > classifying the others. The good news is that the non-trivial ones > are falling neatly into three categories so far, so there hopefully > won't be too many actual changes to make. > > But there a couple of bugs that have me baffled. For example: > test_subs_dict1 in sympy/core/tests/test_subs. > > c2,c3,q1p,q2p,c1,s1,s2,s3= symbols('c2 c3 q1p q2p c1 s1 s2 s3') > test=c2**2*q2p*c3 + c1**2*s2**2*q2p*c3 + s1**2*s2**2*q2p*c3 \ > - c1**2*q1p*c2*s3 - s1**2*q1p*c2*s3 > assert test.subs({c1**2 : 1-s1**2, c2**2 : 1-s2**2, c3**3: 1- > s3**2}) \ > == c3*q2p*(1 - s2**2) + c3*q2p*s2**2*(1 - s1**2) - > c2*q1p*s3*(1 - s1**2) \ > + c3*q2p*s1**2*s2**2 - c2*q1p*s3*s1**2 > > If I create the necessary symbols, and enter > > test.subs({c1**2 : 1-s1**2, c2**2 : 1-s2**2, c3**3: 1-s3**2}) > > I get back > > c3*q2p*(1 - s2**2) + c3*q2p*s2**2*(1 - s1**2) - c2*q1p*s3*(1 - > s1**2) + c3*q2p*s1**2*s2**2 - c2*q1p*s3*s1**2 > > Which is all well and good. But if I then copy and paste these to get > > test.subs({c1**2 : 1-s1**2, c2**2 : 1-s2**2, c3**3: 1-s3**2}) == > c3*q2p*(1 - s2**2) + c3*q2p*s2**2*(1 - s1**2) - c2*q1p*s3*(1 - s1**2) > + c3*q2p*s1**2*s2**2 - c2*q1p*s3*s1**2 > > It returns False. Does anyone have any clue how that could happen? > I'm starting to pull my hair out over this. Try it in isympy, like this: >>> test=c2**2*q2p*c3 + c1**2*s2**2*q2p*c3 + s1**2*s2**2*q2p*c3 - >>> c1**2*q1p*c2*s3 - s1**2*q1p*c2*s3 >>> test.subs({c1**2 : 1-s1**2, c2**2 : 1-s2**2, c3**3: 1-s3**2}) ⎛ 2⎞ 2 ⎛ 2⎞ ⎛ 2⎞ 2 2 c₃⋅q2p⋅⎝1 - s₂ ⎠ + c₃⋅q2p⋅s₂ ⋅⎝1 - s₁ ⎠ - c₂⋅q1p⋅s₃⋅⎝1 - s₁ ⎠ + c₃⋅q2p⋅s₁ ⋅s₂ 2 - c₂⋅q1p⋅s₃⋅s₁ >>> print test.subs({c1**2 : 1-s1**2, c2**2 : 1-s2**2, c3**3: 1-s3**2}) c3*q2p*(1 - s2**2) + c3*q2p*s2**2*(1 - s1**2) - c2*q1p*s3*(1 - s1**2) + c3*q2p*s1**2*s2**2 - c2*q1p*s3*s1**2 >>> test.subs({c1**2 : 1-s1**2, c2**2 : 1-s2**2, c3**3: 1-s3**2}) == c3*q2p*(1 >>> - s2**2) + c3*q2p*s2**2*(1 - s1**2) - c2*q1p*s3*(1 - s1**2) + >>> c3*q2p*s1**2*s2**2 - c2*q1p*s3*s1**2 True Does it work or fail for you? We'll go from there. 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.
