Skip to content
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

assume doesn't interact well with solve #6515

Closed
robertwb opened this issue Jul 12, 2009 · 12 comments
Closed

assume doesn't interact well with solve #6515

robertwb opened this issue Jul 12, 2009 · 12 comments

Comments

@robertwb
Copy link
Contributor

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]

Component: calculus

Author: Robert Bradshaw

Reviewer: Burcin Erocal

Merged: sage-4.3.3.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/6515

@kcrisman
Copy link
Member

comment:1

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.

@kcrisman
Copy link
Member

comment:2

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.

@robertwb
Copy link
Contributor Author

Attachment: 6515-solve-assume.patch.gz

@robertwb
Copy link
Contributor Author

comment:4

It doesn't catch everything, but is better than what we have now.

@burcin
Copy link

burcin commented Feb 3, 2010

Attachment: trac_6515-referee.patch.gz

minor documentation fixes

@burcin
Copy link

burcin commented Feb 3, 2010

Author: Robert Bradshaw

@burcin
Copy link

burcin commented Feb 3, 2010

Reviewer: Burcin Erocal

@burcin
Copy link

burcin commented Feb 3, 2010

comment:5

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?

@robertwb
Copy link
Contributor Author

robertwb commented Feb 3, 2010

comment:6

Thanks for looking at this. Nice catches, I approve of your changes.

@qed777
Copy link
Mannequin

qed777 mannequin commented Feb 10, 2010

comment:7

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.

@qed777
Copy link
Mannequin

qed777 mannequin commented Feb 10, 2010

comment:8

The first patch is missing a Mercurial header and the ticket number. I've applied a refreshed patch to 4.3.3.alpha0.

@qed777
Copy link
Mannequin

qed777 mannequin commented Feb 11, 2010

Merged: sage-4.3.3.alpha0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants