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

Incorrect doctest in sage/misc/functional.py #12845

Closed
orlitzky opened this issue Apr 15, 2012 · 11 comments
Closed

Incorrect doctest in sage/misc/functional.py #12845

orlitzky opened this issue Apr 15, 2012 · 11 comments

Comments

@orlitzky
Copy link
Contributor

We currently have,

sage: a, b, c = var("a, b, c")
sage: v = vector([a, b, c])
sage: bool(norm(v).simplify_full() == sqrt(a^2 + b^2 + c^2))
True

which is true enough if a,b,c are real. The current doctest "works" because somewhere along the line, simplify_full() assumes that they're real. So in effect, this doctest is confirming incorrect behavior.

The proper fix is to explicitly assume that a,b,c are real.


Apply attachment: sage-trac_12845.patch and attachment: trac_12845-reviewer.patch.

CC: @kcrisman

Component: symbolics

Author: Michael Orlitzky

Reviewer: Karl-Dieter Crisman

Merged: sage-5.1.beta3

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

@orlitzky
Copy link
Contributor Author

Add assumptions and use simplify() instead of simplify_full().

@orlitzky
Copy link
Contributor Author

comment:1

Attachment: sage-trac_12845.patch.gz

@orlitzky
Copy link
Contributor Author

Author: Michael Orlitzky

@novoselt
Copy link
Member

comment:2

Should there also be another ticket for fixing the bug of the real assumption?

@orlitzky
Copy link
Contributor Author

comment:3

Replying to @novoselt:

Should there also be another ticket for fixing the bug of the real assumption?

Yes, there are at least two, #12737 and #12780. I separated this patch out because I wound up fixing the same doctest twice.

The first bug, "fixed" by #12737 is that simplify_radical() ignores the domain anyway and goes nuts. "Simplify" there is really a misnomer, so the fix that I settled on was to remove it from simplify_full():

sage: bool(norm(v).simplify_radical() == sqrt(a^2 + b^2 + c^2))
True

The second more sneaky bug, #12780, is that simplify_log() sets the Maxima domain to real before it performs its simplifications. Thus,

sage: bool(norm(v).simplify_log() == sqrt(a^2 + b^2 + c^2))    
True

I think the fix there is straightforward: don't do that. This was the only doctest affected by not setting the domain to real during simplify_log().

@kcrisman
Copy link
Member

comment:5

Do you have to forget() anything for doctests to work properly? I think it's good form to do so at the end of any assumptions tests...

@kcrisman
Copy link
Member

comment:6

Attachment: trac_12845-reviewer.patch.gz

Apply sage-trac_12845.patch and trac_12845-reviewer.patch.

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

Reviewer: Karl-Dieter Crisman

@orlitzky
Copy link
Contributor Author

comment:7

Replying to @kcrisman:

Do you have to forget() anything for doctests to work properly? I think it's good form to do so at the end of any assumptions tests...

Yeah, thanks, I just forgot to add it.

@jdemeyer
Copy link
Contributor

jdemeyer commented Jun 5, 2012

Merged: sage-5.1.beta3

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

5 participants