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

Invalid simplification from Expression.simplify_rational() #12794

Closed
orlitzky opened this issue Apr 2, 2012 · 7 comments
Closed

Invalid simplification from Expression.simplify_rational() #12794

orlitzky opened this issue Apr 2, 2012 · 7 comments

Comments

@orlitzky
Copy link
Contributor

orlitzky commented Apr 2, 2012

Well, I thought this one was safe. Not so!


sage: u,x = var('u,x')
sage: F = -1/12*(2*(sqrt(24*sqrt(2) - 30)*(155*sqrt(2) - 228) + 2368*sqrt(2) - 3086)*u^3 + (8*(5*(3*sqrt(2) - 4)*sqrt(24*sqrt(2) - 30) - 128*sqrt(2) + 106)*u^3 + 32*(5*(3*sqrt(2) - 4)*sqrt(24*sqrt(2) - 30) - 128*sqrt(2) + 106)*u^2 + (sqrt(24*sqrt(2) - 30)*(385*sqrt(2) - 492) - 6976*sqrt(2) + 6902)*u)*x^3 + 2*(sqrt(24*sqrt(2) - 30)*(525*sqrt(2) - 764) + 6592*sqrt(2) - 8834)*u^2 + 3*(8*(5*(3*sqrt(2) - 4)*sqrt(24*sqrt(2) - 30) - 128*sqrt(2) + 106)*u^3 + 32*(5*(3*sqrt(2) - 4)*sqrt(24*sqrt(2) - 30) - 128*sqrt(2) + 106)*u^2 + (sqrt(24*sqrt(2) - 30)*(575*sqrt(2) - 788) - 1216*sqrt(2) - 118)*u)*x^2 + (5*sqrt(24*sqrt(2) - 30)*(191*sqrt(2) - 276) + 10304*sqrt(2) - 14158)*u + 3*(8*(5*(3*sqrt(2) - 4)*sqrt(24*sqrt(2) - 30) - 128*sqrt(2) + 106)*u^3 + 2*(sqrt(24*sqrt(2) - 30)*(335*sqrt(2) - 468) + 832*sqrt(2) - 1814)*u^2 + (sqrt(24*sqrt(2) - 30)*(765*sqrt(2) - 1084) + 4544*sqrt(2) - 7138)*u)*x)/(sqrt(24*sqrt(2) - 30)*(95*sqrt(2) - 148) + 2880*sqrt(2) - 3510)
sage: b = -1/6*(128*x^3 + 384*x^2 + 6*sqrt(24*sqrt(2) - 30)*((3*sqrt(2) - 4)*x + 3*sqrt(2) - 4) + (x + 1)*sqrt(9216*sqrt(2) + 1216*x^4 + 22144*x^3 + 16*(576*sqrt(2) - 1253)*x + 13056*x^2 + 24*sqrt(24*sqrt(2) - 30)*(4*(3*sqrt(2) - 4)*x^4 - 8*(3*sqrt(2) - 4)*x^3 + 16*(3*sqrt(2) - 4)*x^2 + 25*(3*sqrt(2) - 4)*x - 9*sqrt(2) + 12) - 12176) + 204*x - 52)/(16*x^3 + 48*x^2 + (3*sqrt(2) - 4)*sqrt(24*sqrt(2) - 30) + 48*x - 14)
sage: p  = plot(F(u=b), x, -1, 0)
sage: p += plot(F(u=b).simplify_rational(), x, -1, 0, color='red')
sage: p

Component: symbolics

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

@orlitzky orlitzky added this to the sage-5.11 milestone Apr 2, 2012
@orlitzky
Copy link
Contributor Author

orlitzky commented Apr 2, 2012

A .sage file exhibiting the problem

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

kcrisman commented Apr 3, 2012

comment:1

Attachment: simplify_rational_gone_wild.sage.gz

If you could narrow it down, that would be helpful. I'm adding this to the description, as well as the graphic.

@kcrisman
Copy link
Member

kcrisman commented Apr 3, 2012

Shows the problem

@kcrisman
Copy link
Member

kcrisman commented Apr 3, 2012

comment:2

Attachment: tmp_0.png

But I should point out that there are lots of cool examples of "simplification" actually making things simpler. Could this just be a loss of significance error? Otherwise, try

sage: plot(((x^3+4)^2-x^6)/x^3,(x,0,10^6))

(courtesy of the calculus text we currently teach from here).

So I'm more concerned about the left end of your graph than the right.

@kcrisman
Copy link
Member

Attachment: better.png

shows the solution!

@kcrisman
Copy link
Member

comment:3

The attached picture actually is for #12795, but as it was the same, it's still worth posting here too. I think they are probably both invalid, or more precisely are warnings about how rewriting expressions in different ways allows for a lot of numerical error to creep in. Good stuff. (Not good enough for me to want to teach a numerical analysis course, but good enough for me to want to take a numerical analysis course...)

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@orlitzky orlitzky removed this from the sage-6.4 milestone Dec 4, 2015
@vbraun vbraun closed this as completed Dec 4, 2015
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