New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plus-minus object #5305
Comments
I think it's probably more trouble than it's worth. You'd have to have to make sure that everything handles correctly expressions that hold two values at once. For instance, what would happen with limit(x**pm, x, 0)? Also, how would you get back from expressions with pm to ordinary expressions, e.g. pm * x -> [x, -x]? Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c1 |
I didn't think of things like For By the way, you can think of it as being similar to having something like sign(t) multiplying the terms instead of pm, where t is just some parameter. So really computing Actually, the only thing I see as really a potential problem is that mp should always equal -pm. But I'm not entirely sure if that would even ever come up as an issue or not. Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c2 |
+1 on the cool idea. Surprising how its not already there. So should stuff like limit(x**pm, x, 0) return a 2-tuple, and maybe check to see if the tuple can again be converted back to a single expr with pm in it. Sage doesn't have this support. It might be for a reason. Aaron, pm differs from other symbols because, other symbols are expected to have ONE value, while pm has two. So we can't treat it as just another Symbol. But, I think its worth it, A symbolic mathematics library should have this, even if the implementation is somewhat non-trivial. Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c3 |
When you say x = Symbol('x', real=True), you are saying essentially "let x be an arbitrary element of the set R". This is exactly the same thing with pm, except it is an arbitrary element of the set {-1, 1}. Now, since the latter is a finite set, we can expand it out to all possibilities, but as just pm, it is no different from a Symbol. The only special thing here is mp, which is equal to negative of whatever pm is. In fact, if we ever get our new assumptions in, we might be able to extend the idea to a Symbol that is assumed to be an arbitrary element of any set that can be symbolically represented by the system (finite or infinite). Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c4 |
Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c5 |
Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c6 |
Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c7 |
Original comment: http://code.google.com/p/sympy/issues/detail?id=2206#c8 |
Please, fix this. |
What about introducing a PlusMinus fancy set: PlusMinus(foo) iterates as -foo, +foo? |
A set expression would work. One issue is that all instances of |
I'm not sure this a good idea since plus-minus isn't a mathematical function and can mean different things depending on the context. For example, in statistics it can represent the uncertainty in a confidence interval. However, it is useful for printing. I subclassed |
I like the idea of a special symbol. @meganly, instead of subclassing Add (which can take more args and requires the |
If the assumptions system supported arbitrary input domains (rather than just |
With a set, how are you imagining that the two would be distinct? |
The point is that |
Do others think this would be useful?
I think we should have an object that represents plus-minus (±), and another to represent minus-plus (∓) .
They would probably be called pm and mp or something. The behavior would be
There are many cases where you want to keep track of two expressions that differ only by a plus/minus sign somewhere in the expression (like conjugates or something), and I think an object like this would be useful.
Original issue for #5305: http://code.google.com/p/sympy/issues/detail?id=2206
Original author: https://code.google.com/u/asmeurer@gmail.com/
Original owner: https://code.google.com/u/asmeurer@gmail.com/
The text was updated successfully, but these errors were encountered: