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

performance of checking if (c/d)^(a/b) is rational #10629

Closed
williamstein opened this issue Jan 13, 2011 · 6 comments
Closed

performance of checking if (c/d)^(a/b) is rational #10629

williamstein opened this issue Jan 13, 2011 · 6 comments

Comments

@williamstein
Copy link
Contributor


sage: f(z) = (((-2)^z + 3^z)/((-2)^z - 3^z))^(1/z)
sage: f(2)
sqrt(-13/5)
sage: f(10)
(-60073/58025)^(1/10)
sage: f(100)
(-515377520732011332304111729993850674198810727377/515377520732011329768810529537391871205404316625)^(1/100)

sage: f(100)
(-515377520732011332304111729993850674198810727377/515377520732011329768810529537391871205404316625)^(1/100)
sage: f(110)
(-30432527221704537087670067466163877438919371148942073/30432527221704537085073919036896463624654122984332025)^(1/110)
sage: f(120)
(-1797010299914431210414509057505389955604379434598131450977/1797010299914431210411850601513820123858571820477570761825)^(1/120)
sage: f(140)
(-6265787482177970379256225588138505240370640792793057315382192174577/6265787482177970379256222800545355424042748100828273234337003927025)^(1/140)
sage: f(160)
(-21847450052839212624230656504451736779897953023116436713529106968318864898177/21847450052839212624230656501528733505236147186709067048096540929006999812225)^(1/160)
sage: f(180)
(-76177348045866392339289727720617094245965667291253555071028716054140756082155221621777/76177348045866392339289727720614029254883935513536838376974415435773518603910854417425)^(1/180)

... and these start getting INSANELY SLOW. Why?

(This was found by Vladimir V. Bondarenko.)

Component: symbolics

Reviewer: Ralf Stephan, Karl-Dieter Crisman

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

@williamstein
Copy link
Contributor Author

comment:1

Note the traceback:


/Users/wstein/sd27/sage-4.6.1.rc1/local/lib/python2.6/site-packages/sage/rings/arith.pyc in __factor_using_pari(n, int_, debug_level, proof)
   2140         pari.set_debug_level(debug_level)
   2141         
-> 2142     F = pari(n).factor(proof=proof)
   2143     B = F[0]
   2144     e = F[1]

...

so it is factoring.

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

rwst commented Feb 1, 2015

comment:7

Replying to @dandrake:

So we need to factor to decide if the result is in the rationals or not.

Can someone explain this further? I mean technically, factoring is overkill for this---if the exponent is a rational a/b then it suffices to check if the base is a b-th power, doesn't it?

@rwst rwst changed the title weird performance issue -- why is this SOOOO slow !? performance of checking if (c/d)^(a/b) is rational Feb 1, 2015
@rwst
Copy link
Contributor

rwst commented Feb 1, 2015

comment:9

Ah ok, it's not so important to decide whether rational or not, but to get the "rational power parts" in order to get a simplified expression of form x*y^(a/b). Since there is no way out of factoring I propose to close the ticket.

@rwst rwst removed this from the sage-6.4 milestone Feb 1, 2015
@kcrisman
Copy link
Member

kcrisman commented Feb 3, 2015

Reviewer: Ralf Stephan, Karl-Dieter Crisman

@kcrisman
Copy link
Member

kcrisman commented Feb 3, 2015

comment:10

Hmm, but one could possibly ask for it not to do that simplified form, to just always go straight to the symbolic ring... but in this case I agree that unless William really complains, we can close this.

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

7 participants
@burcin @vbraun @rwst @williamstein @kcrisman @jdemeyer and others