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_trig() #12795

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

Invalid simplification from Expression.simplify_trig() #12795

orlitzky opened this issue Apr 2, 2012 · 7 comments

Comments

@orlitzky
Copy link
Contributor

orlitzky commented Apr 2, 2012

Same issue as #12794 from the looks of it. Maybe this is just a particularly nasty function?

u,x = var('u,x')

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)

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)

p  = plot(F(u=b), x, -1, 0)
p += plot(F(u=b).simplify_trig(), x, -1, 0, color='red')
p.show(filename='simplify_trig_gone_wild.png')

CC: @kcrisman

Component: symbolics

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

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

orlitzky commented Apr 2, 2012

Attachment: simplify_trig_gone_wild.sage.gz

A .sage file exhibiting the problem

@orlitzky

This comment has been minimized.

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

comment:4

I'm inclined to believe it's a pretty nasty function. Given that the simplifications in both cases appear to be the same (and that G.expand() gives a different, but still correct, thing without numerical issues), I think the problem is just that you lose too much accuracy. See my comment on #12794.

@kcrisman
Copy link
Member

shows solution

@kcrisman
Copy link
Member

comment:5

Attachment: better.png

Thanks for pointing out #12795, which got me trying this out again... Pretty sure this is invalid.

sage: G = F(u=b)
sage: H = G.simplify_trig()
sage: R = RealField(1000)
sage: L = [(j,H(R(j))) for j in srange(-1,.2,.001)]
sage: M = [(a,R(b)) for a,b in L] # should have done this in one step, but oh well
sage: points(M)+plot(G,(x,-1,.2),color='red')

yields the following bee-yoo-tiful picture that every student of mathematics should have the chance to understand - why you don't just plug and chug:

@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
Copy link
Contributor Author

orlitzky commented Dec 4, 2015

comment:10

You are right about these, I should have closed them earlier. The problem is with plot() using floats. The result of simplify_rational() is still accurate.

@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