Opened 7 years ago
Last modified 4 years ago
#12554 new enhancement
Adding a "swap" method to equation objects.
Reported by: | JoalHeagney | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-6.4 |
Component: | symbolics | Keywords: | swap, left hand side, right hand side, inequalities |
Cc: | Merged in: | ||
Authors: | Ivan Andrus, Joal Heagney | Reviewers: | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Often when working with sage equations, it's desirable to swap the left and right hand side of the equations. (Makes substitutions easier for a start, allows manual solving of inequalities, etc.)
A model implementation by Ivan Andrus https://groups.google.com/forum/#!topic/sage-support/lKbMSQrFhGg (in function form) is supplied below (with some rearrangement so equal operator case is tested first):
import operator def reverse_inequality(eq): """ Reverse the order of the inequality without changing it's meaning. """ orig_op = eq.operator() # The "top-level" operator if orig_op == operator.eq: op = operator.eq elif orig_op == operator.lt: op = operator.gt elif orig_op == operator.le: op = operator.ge elif orig_op == operator.gt: op = operator.lt elif orig_op == operator.ge: op = operator.le elif orig_op == operator.ne: op = operator.ne else: raise TypeError, "this expression must be a relation" return op(eq.rhs(), eq.lhs())
My request is that something similar be attached to equation objects as a method.
Change History (7)
comment:1 Changed 7 years ago by
comment:2 Changed 6 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:3 Changed 5 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:4 Changed 5 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:5 Changed 5 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:6 Changed 4 years ago by
- Component changed from algebra to symbolics
- Owner changed from AlexGhitza to burcin
comment:7 Changed 4 years ago by
- Owner changed from burcin to (none)
Note: See
TracTickets for help on using
tickets.