On Aug 3, 2009, at 10:27 PM, Alemi wrote: > > Hi, > > I'm looking to use SymPy for a project I'm working on and I have a > couple questions. > > The first is that I think I might want to disable the flattening of > equations by default. I looked at the code and tried to change the > core, especially add.py and operations.py but couldn't quite hack it. > I guess, the first question would be whether there would be a simple > way to do this, and the second would be that if I did dive deeper and > disable the flatten by default but maintained the same object > structure, would this screw with any of the more sophisticated > mathematical operations, i.e. do any of the other functions rely on > expressions being in their flattened form to function correctly. The only way to have things not flatten is to call the classes directly and do evaluate=False. For example: >>> Mul(x, x, evaluate=False) x⋅x
Quite a few functions do rely on expressions being flattened, so don't be surprised if they fail. > > The second question is whether there is any interest in adding support > for equations much like SAGE does, i.e. store 'x+2==3' as an object > itself with the equals operator and a bunch of methods like > add_to_both_sides and the like. If not, do you think I could throw > that together without interfering too much with how SymPy does its own > thing? Any tips before I embark? SymPy already has an Equality class, but things like addition to both sides are not implemented yet. It needs to be supported for the + andso on operators directly, in my opinion. You would need to add cases to the flatten methods of Add and Mul. It would be really easy, if you add an Equality to an Equality, return Equality(eq1.lhs + eq2.lhs, eq1.rhs + eq2.rhs) and the same for Mul. Anything else would just be added to both sides, like Equality(eq1.lhs + expr, eq2.rhs + expr). Equality probably also needs a _eval_power method to handle things like Equalty(x, y)**2 to Equality(x**2, y**2). There are also <, >, =<, and => classes (see sympy/core/relational.py), that probably should have similar support. Note that you can also do Eq(x, y) to mean Equality(x, y) If you want to implement these things, please send in a patch. Aaron Meurer > Thanks. > > Best Regards, > > Alex Alemi > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
