Aaron, Chris, Thanks for the replies! Aaron wrote: > This is great. SymPy code is *MUCH* easier to read than some lisp, in my > opinion.
So far, yes and no. The main thing is that I needed to implement structured "tuples" as defined in SICM, and functions that take tuples as arguments, and derivatives/partial derivatives of those functions. I defined my own class for those things, but with higher-order functions (functions that return functions, which is done all the time in SICM) it gets a bit inelegant. Still, I think most of the infrastructure is done: I will put up what I have, and ask about prettyfication, shortly. Chris wrote: > what you could try doing is "masking" the derivatives--replace them > with symbols of your own That's exactly what I ended up doing, but in a much more longwinded way than what you wrote. The other issue that came up is, I see from the archives, again a known problem: if I want to define multiplication for "tuples", a multiplication of a tuple by a scalar (on the left or the right) is the tuple of each component multiplied by the scalar. I define the __mul__ and __rmul__ methods, but __rmul__ fails to get called when the scalar is a sympy object, because scalar defines a __mul__ that can handle other sympy objects and I get, eg, r * (1,2) instead of (r, 2*r) (I am using the Basic class for my tuples). If I don't know that r is a scalar, of course, the first answer is right and the second need not be right. But even when r is a sympified number, it fails to expand: a = up(1,2) # (up and down are tuple-generating functions in my library) b = 3 b*a (output)=> (3, 6) (desired answer) b = sympify(3) b*a (output)=> 3⋅(1, 2) (not the desired answer!) I am currently using the workaround of unsympifying all numbers... Rahul -- 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.
