Opened 12 years ago
Closed 11 years ago
#6515 closed defect (fixed)
assume doesn't interact well with solve
Reported by: | robertwb | Owned by: | burcin |
---|---|---|---|
Priority: | major | Milestone: | sage-4.3.3 |
Component: | calculus | Keywords: | |
Cc: | Merged in: | sage-4.3.3.alpha0 | |
Authors: | Robert Bradshaw | Reviewers: | Burcin Erocal |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
This has been brought up several times on the mailing lists. As a specific example
sage: assume(x>0) sage: solve([x^2-1],x) [x == -1, x == 1]
At the very least, we could probably filter out the "solutions" that violate the assumptions.
sage: [all(a.subs(s) for a in assumptions()) for s in solve(x^2-1==0, x)] [False, True]
Attachments (2)
Change History (11)
comment:1 Changed 12 years ago by
comment:2 Changed 11 years ago by
Update: the solution above works well for single equations in one variable, but is tricky to implement for multiple equations (you can't subs x+y==3, for instance). Also, one has to keep in mind how to check assumptions like 'x is Integer', which can't be subs'ed in.
Changed 11 years ago by
comment:3 Changed 11 years ago by
- Report Upstream set to N/A
- Status changed from new to needs_review
comment:4 Changed 11 years ago by
It doesn't catch everything, but is better than what we have now.
comment:5 Changed 11 years ago by
- Reviewers set to Burcin Erocal
The patch looks good and doctests pass. There is one minor problem, the line
sage: GenericDeclaration(x, 'rational').contradicts(y==pi)
is repeated several times in the doctest for sage.symbolic.assumptions.GenericDeclaration.contradicts()
.
I attached a patch to change these lines and add an INPUT
field to the docstring. Can you look over my patch and change the status to positive_review if you agree with the changes?
comment:6 Changed 11 years ago by
- Status changed from needs_review to positive_review
Thanks for looking at this. Nice catches, I approve of your changes.
comment:7 Changed 11 years ago by
For the record: Applying the patch to 4.3.2 + a long queue gives
applying 6515-solve-assume.patch patching file sage/symbolic/expression.pyx Hunk #2 succeeded at 5952 with fuzz 2 (offset 40 lines). Hunk #3 succeeded at 6037 with fuzz 1 (offset 83 lines).
Please let us know (via sage-devel) about the best order in which to apply the symbolics and calculus patches.
comment:8 Changed 11 years ago by
The first patch is missing a Mercurial header and the ticket number. I've applied a refreshed patch to 4.3.3.alpha0.
comment:9 Changed 11 years ago by
- Merged in set to sage-4.3.3.alpha0
- Resolution set to fixed
- Status changed from positive_review to closed
It sounds like Maxima (intentionally?) doesn't use assumptions in solve, see for instance http://www.math.utexas.edu/pipermail/maxima/2008/013152.html and other similar threads. The above solution seems reasonable.