Opened 3 years ago
Last modified 2 weeks ago
#28599 new defect
RecursionError and AssertionError with regular_polygon
Reported by: | jipilab | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.7 |
Component: | geometry | Keywords: | polytopes |
Cc: | gh-LaisRast, gh-kliem, chapoton | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | public/28599 (Commits, GitHub, GitLab) | Commit: | 631b94b7ed3fd8da9ba96991991e80427f0dd0a6 |
Dependencies: | Stopgaps: |
Description
On sage 8.9 with python3, we get:
sage: polytopes.regular_polygon(16) Traceback (most recent call last): ... RecursionError: maximum recursion depth exceeded while calling a Python object
and
sage: polytopes.regular_polygon(20) Traceback (most recent call last): ... AssertionError:
The full traceback of the AssertionError? is in the first comment.
Change History (14)
comment:1 Changed 3 years ago by
comment:2 Changed 3 years ago by
- Cc chapoton added
comment:3 Changed 2 years ago by
Minkowski sum of 3-gon and 8-gon fails for the same reason (it seems).
comment:4 Changed 2 years ago by
At least one of the problems, is the following polynomial:
sage: x = polygen(ZZ) sage: p = x^4 - 953242354297818724703752509373294008993273880281503307750881459277750989380210829785430344332714372666685310888689163811627075803785878367343692267581868674262355536461240142664284693519394320653419989280981931805310642862110901030273756885722766438135722802125006982946730724089134972591648337179521335895506775892738040105250933785771678155298317930004572772706441205753132338170152805126505944177047591555414048614851799823325762040314246803785681217733628382625000/284661951904002202872640993073205372416085601*x^3 - 30712408728906837824436007395092863393836220556802908122405411503081893159534141046069917986518336650545184126375010296928998481657806406857280482570044966602970260824315388496271886156173475632228775359363070522704917567091005272564855859697539608132911947005950096833560245019249568419051453764745401260372146567432451459223482349455309387869128311408655626767098132057167066233264536886082536577749189845977342878132470579789445774525718429978750519923342579434950186624065140771232331860100535974716501530945373865273425252510527953175579253592022574532890542167552861231034786647165904068730166174154795302005807689993179771568339570525442184834458807496917824671504027310965100488346287613993408253136785746604795218431006804536475561431339093750000000/61119530504912696648935481199357970727*x^2 + 150921795442076031594623634352258246928488601400691240728540852473716672256682293428050838677947801687982699333615624718673041296948797660444940045131964082794334457693026029279281277048105532811535029576642684802051588919579838547672743504092642260363727743689262032542903034987995250319363859289381240034229894990128060909169794469573280531854720460953346200798634612581776964357250718226442893373286570213966569630517443223997021564703857421875000000/4657463*x + 422747915860318694374364472032237141148264052306702220749481741945894045574142738635283553650690525693771951595075694700927009281158447265625000000 sage: p.roots(QQbar) [(-1.500582791467851?e296, 1), (-1.304604660101746?e-299, 1), (6.44864813030324?e-275, 1), (3.348681999550417?e423, 1)]
This works and it produces 4 real roots, as far as I can see. However, in AA
it leads to the above type error.
Now on sage 8.9 with python2, it produces one root with AA
and four roots with QQbar
. So it didn't exactly work perfectly, but just good enough.
comment:5 Changed 2 years ago by
- Branch set to public/28599
- Commit set to 631b94b7ed3fd8da9ba96991991e80427f0dd0a6
I attached a very rough fix of the AssertionError
.
It seems there is a random splitting that sometimes suceeds and sometimes not.
Even in python2 the following fails (it usually fails on one of the first tries, range(20)
is just for good measure).
sage: from sage.rings.polynomial.real_roots import * sage: x = polygen(ZZ) sage: p = x^4 - 953242354297818724703752509373294008993273880281503307750881459277750989380210829785430344332714372666685310888689163811627075803785878367343692267581868674262355536461240142664284693519394320653419989280981931805310642862110901030273756885722766438135722802125006982946730724089134972591648337179521335895506775892738040105250933785771678155298317930004572772706441205753132338170152805126505944177047591555414048614851799823325762040314246803785681217733628382625000/284661951904002202872640993073205372416085601*x^3 - 30712408728906837824436007395092863393836220556802908122405411503081893159534141046069917986518336650545184126375010296928998481657806406857280482570044966602970260824315388496271886156173475632228775359363070522704917567091005272564855859697539608132911947005950096833560245019249568419051453764745401260372146567432451459223482349455309387869128311408655626767098132057167066233264536886082536577749189845977342878132470579789445774525718429978750519923342579434950186624065140771232331860100535974716501530945373865273425252510527953175579253592022574532890542167552861231034786647165904068730166174154795302005807689993179771568339570525442184834458807496917824671504027310965100488346287613993408253136785746604795218431006804536475561431339093750000000/61119530504912696648935481199357970727*x^2 + 150921795442076031594623634352258246928488601400691240728540852473716672256682293428050838677947801687982699333615624718673041296948797660444940045131964082794334457693026029279281277048105532811535029576642684802051588919579838547672743504092642260363727743689262032542903034987995250319363859289381240034229894990128060909169794469573280531854720460953346200798634612581776964357250718226442893373286570213966569630517443223997021564703857421875000000/4657463*x + 422747915860318694374364472032237141148264052306702220749481741945894045574142738635283553650690525693771951595075694700927009281158447265625000000 sage: factor, left, right = (284661951904002202872640993073205372416085601*x^4 - 953242354297818724703752509373294008993273880281503307750881459277750989380210829785430344332714372666685310888689163811627075803785878367343692267581868674262355536461240142664284693519394320653419989280981931805310642862110901030273756885722766438135722802125006982946730724089134972591648337179521335895506775892738040105250933785771678155298317930004572772706441205753132338170152805126505944177047591555414048614851799823325762040314246803785681217733628382625000*x^3 - 143041907295760627614311200310371392820846625303148942872502675075378303360483359158851938435243651771458124896778934582565824055377412001100730128192129340289569679889598422252011947712590184338507128771545204525888813486776374689775731266874481915913536475438173355848723999448089152677700641005512410790336638868393647670629377773741173627553113952638291461409569167425369495799978949759064629057013474987615173293215490823957891485359876136044121332773730900042841401044678302731806050042139422582411041369821433798677962996833441052380992877172462236051679983195317251727678970522069253061660205939977515391665875101258705038427993521158137534505653020941017382448017161551809449815754765749532581182879213553739209352419332244876867077770688869594156250000000*x^2 + 9224269280378159995086175956599156896246052775964623781473039459314278625189639357821542855810535420201241102250640064464729153254638828194214182633761289776904830148558523602353033080183173926606667803263737366192099310316607083404573347178766118989259952930345144406752496177427851926390971866913094192923444722805841141305928789763257595182877391253154218411290329529480038030212118404992939819004238133784189703469017999758183942287839221428776394999468692651292391209137939453125000000*x + 120340246892147210219925300245948427935624593297607357599380720896699146352972193191072575586572678017171737630079862986465889308813652352169438608150972047865521402530851444244384765625000000, -300116558293571858482887344849275704852462363716019298869701069535049699520357009140806578533610775590465036648456421628927951845701119829826990780533505317207095422744616966278783897429699030687513847719851964893907284704084454895267147108732448327646270701568981710607368843500980539555936468992, 6697363999101269501879270474853023006070891635062527574088015888493332207497411312232478630319160871182105545664990115586397447784674611836869069877381887649421512272089736918413918361100105903569317442150105716914981851659214570137801851169316697850787303236156131820593525165861969674761404545709833999974365728934357748559327296686364108483990990732078449920377271073812649747385445940616777427079802648444067616380682240) sage: b, _ = to_bernstein(factor, left, right) sage: for _ in range(20): ....: oc = ocean(ctx, bernstein_polynomial_factory_ratlist(b), linear_map(left, right)) ....: oc.find_roots()
The RecursionError
is not due to python3. I can confirm it on 8.9 with python2.
New commits:
631b94b | fixed assertion error
|
comment:6 Changed 2 years ago by
- Milestone changed from sage-9.0 to sage-9.1
Ticket retargeted after milestone closed
comment:7 Changed 2 years ago by
Ok, sorry for the code below: it is really absurd, but this is a minimal example that reproduces the assertion error in qqbar.py
:
sage: R.<y> = QQ[] ....: v = QQbar.polynomial_root(AA.common_polynomial(y^8 - y^6 + y^4 - y^2 + 1), CIF(RIF(RR(0.95105651629515353), RR(0.95105651629515364)), RIF(-RR(0.30901699437494745), -RR(0.3090169943749474)))) ....: a_number = AA(-1773771227584385815111706893900949861104891064242305307966022333822496428028500035508902583036959204537264766688321220890672517171823317808444268672562745271414504003966433029471689554196791 ....: 5196235296422815147978121107870040525130223651405219411067699495095272994455972342474052940895134978233663383602877952342919741122636119080859978049638078126779759346806919160609037291355471699756013044209 ....: 5483312355231935640717206940736751368480492837953720652079332615152682064295095556319063104680015601631633229123069680423355253651835771389161420669292788796852682051422632099371271239353524132124196618633 ....: 2160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v^7 - 12887202317923319885943420189176756357017971481590243494049948312127392394950104866911220670604451981908195 ....: 8371080579394652756244399575137821254432548212435032939204787697691800132061253609371701669030357778863333316506044361636419736535751486490104132379200110340372244885858365012832634472573036026206878368127 ....: 4403312308602332477387245462097752958540406894753567138144162162830699381430715772140638003750075504753961256023217632033417260215017516961209975697136152079055069133883360478756682301727586481082919679927 ....: 346903746616198168008384223379509077316072155415326731906073506029658642131621102223360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v^6 + 109625090691377547730317 ....: 5525461587798537717289790603520304664538731755281336113088133438052235985811711264623428593477576263418689317982595042012576163465389907461365436265806375130916851598442483541901104806315869307809855562740 ....: 6445672120427286487049790216349623417313217054330667097678476903242997891805602152830197407775897647700836990651946532719071456891625597407900569788677899489585009768054349575473650811338764570104063140021 ....: 2125979916738435487238216764650063240891980812637635866900695826461943011019456949752340956493135510291161033135835062005451967614863014799283888581011579510801276338176000000000000000000000000000000000000 ....: 0000000000000000000000000000000000000000000000000000*v^5 + 12887202317923319885943420189176756357017971481590243494049948312127392394950104866911220670604451981908195837108057939465275624439957513782125443 ....: 2548212435032939204787697691800132061253609371701669030357778863333316506044361636419736535751486490104132379200110340372244885858365012832634472573036026206878368127440331230860233247738724546209775295854 ....: 0406894753567138144162162830699381430715772140638003750075504753961256023217632033417260215017516961209975697136152079055069133883360478756682301727586481082919679927346903746616198168008384223379509077316 ....: 072155415326731906073506029658642131621102223360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v^4 - 418730586243165139494644157022225735970543515338901732643306743 ....: 6410141346437261407579735214350124188852644801688657342618543202068126473816397564797641855084004187269060985832785722795064053653435541599280978339265048327070729682667692835635161906400085337426252378654 ....: 0916346083933002219755728226121807332519627406536929156762145416959316658149386583835669763320342067638482218840992231569753265603679154241080586058084461344511431943759121879756218895143818376618062186688 ....: 4053062121670537857900212906568989692334761494282611504996314209013969788813271582218838070939302272965378084990268974059340431360000000000000000000000000000000000000000000000000000000000000000000000000000 ....: 000000000000*v^3 + 219250181382755095460635105092317559707543457958120704060932907746351056267222617626687610447197162342252924685718695515252683737863596519008402515232693077981492273087253161275026183370 ....: 3196884967083802209612631738615619711125481289134424085457297409958043269924683462643410866133419535695380648599578361120430566039481555179529540167398130389306543814291378325119481580113957735579897917001 ....: 9536108699150947301622677529140208126280042425195983347687097447643352930012648178396162527527173380139165292388602203891389950468191298627102058232206627167012401090393522972602959856777716202315902160255 ....: 26763520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v + 208519313702963597792336448786317458130536687422413888526129565922315681346997072734539440533222683616661 ....: 4384583809766515221558834445288019146840810180903574691941264335750287299470453620747381862497725467514438329784936550147777229904858656572513646687903172788172469701042793458805351874145798281602789169681 ....: 1948462863215323138930427663128389970365407923962972793099139809598960779704194025933542338930154982759123957616825638010555288518111106330271564293946050035319773173496755745234560502323512208937117129886 ....: 49294252668653137958243183218418023585981434178543521437938796526970908651227517508648960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) + AA(1773771227584385815111 ....: 7068939009498611048910642423053079660223338224964280285000355089025830369592045372647666883212208906725171718233178084442686725627452714145040039664330294716895541967915196235296422815147978121107870040525 ....: 1302236514052194110676994950952729944559723424740529408951349782336633836028779523429197411226361190808599780496380781267797593468069191606090372913554716997560130442095483312355231935640717206940736751368 ....: 4804928379537206520793326151526820642950955563190631046800156016316332291230696804233552536518357713891614206692927887968526820514226320993712712393535241321241966186332160000000000000000000000000000000000 ....: 000000000000000000000000000000000000000000000000000000*v^7 + 128872023179233198859434201891767563570179714815902434940499483121273923949501048669112206706044519819081958371080579394652756244399575137821254 ....: 4325482124350329392047876976918001320612536093717016690303577788633333165060443616364197365357514864901041323792001103403722448858583650128326344725730360262068783681274403312308602332477387245462097752958 ....: 5404068947535671381441621628306993814307157721406380037500755047539612560232176320334172602150175169612099756971361520790550691338833604787566823017275864810829196799273469037466161981680083842233795090773 ....: 16072155415326731906073506029658642131621102223360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v^6 - 1096250906913775477303175525461587798537717289790603520304664 ....: 5387317552813361130881334380522359858117112646234285934775762634186893179825950420125761634653899074613654362658063751309168515984424835419011048063158693078098555627406445672120427286487049790216349623417 ....: 3132170543306670976784769032429978918056021528301974077758976477008369906519465327190714568916255974079005697886778994895850097680543495754736508113387645701040631400212125979916738435487238216764650063240 ....: 8919808126376358669006958264619430110194569497523409564931355102911610331358350620054519676148630147992838885810115795108012763381760000000000000000000000000000000000000000000000000000000000000000000000000 ....: 000000000000000*v^5 - 128872023179233198859434201891767563570179714815902434940499483121273923949501048669112206706044519819081958371080579394652756244399575137821254432548212435032939204787697691800132061 ....: 2536093717016690303577788633333165060443616364197365357514864901041323792001103403722448858583650128326344725730360262068783681274403312308602332477387245462097752958540406894753567138144162162830699381430 ....: 7157721406380037500755047539612560232176320334172602150175169612099756971361520790550691338833604787566823017275864810829196799273469037466161981680083842233795090773160721554153267319060735060296586421316 ....: 21102223360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v^4 + 4187305862431651394946441570222257359705435153389017326433067436410141346437261407579735214350124188 ....: 8526448016886573426185432020681264738163975647976418550840041872690609858327857227950640536534355415992809783392650483270707296826676928356351619064000853374262523786540916346083933002219755728226121807332 ....: 5196274065369291567621454169593166581493865838356697633203420676384822188409922315697532656036791542410805860580844613445114319437591218797562188951438183766180621866884053062121670537857900212906568989692 ....: 334761494282611504996314209013969788813271582218838070939302272965378084990268974059340431360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*v^3 - 219250181382755095 ....: 4606351050923175597075434579581207040609329077463510562672226176266876104471971623422529246857186955152526837378635965190084025152326930779814922730872531612750261833703196884967083802209612631738615619711 ....: 1254812891344240854572974099580432699246834626434108661334195356953806485995783611204305660394815551795295401673981303893065438142913783251194815801139577355798979170019536108699150947301622677529140208126 ....: 2800424251959833476870974476433529300126481783961625275271733801391652923886022038913899504681912986271020582322066271670124010903935229726029598567777162023159021602552676352000000000000000000000000000000 ....: 0000000000000000000000000000000000000000000000000000000000*v - 2085193137029635977923364487863174581305366874224138885261295659223156813469970727345394405332226836166614384583809766515221558834445288019146 ....: 8408101809035746919412643357502872994704536207473818624977254675144383297849365501477772299048586565725136466879031727881724697010427934588053518741457982816027891696811948462863215323138930427663128389970 ....: 3654079239629727930991398095989607797041940259335423389301549827591239576168256380105552885181111063302715642939460500353197731734967557452345605023235122089371171298864929425266865313795824318321841802358 ....: 5981434178543521437938796526970908651227517508648960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) ....: sage: bool(a_number)
a_number
seems to be pretty close to zero, but evaluating bool(a_number)
is just too much to handle...
Looking at this, I am really stunned by the size of the coefficients there... Even better, if before running bool(a_number)
we ask for its minimal polynomial, it changes its repr(!?) and then it is possible to evaluate bool(a_number)
without an issue. What the heck?
sage: a_number 0.?e672 sage: a_number.minpoly() x sage: a_number 0 sage: bool(a_number) False
comment:8 Changed 2 years ago by
For the recursion error, it is obtained through the following:
sage: R.<x> = QQ[] ....: p = x^4 - 785085354174377760378543488111323044749776571631209495946379816236515588853583855784535326960526508097636330877798625485321064091382548770084769695089257246049553938280772932180561801873783457940 ....: 7623236326202557782135972832786016308591922054201949779233079296*x^3 - 39106193696419400676420574963932594736160172155690837888708921665618371452344263107004249679119699863114892743908514315776394551509920 ....: 758420273580999694164311317393649793536718487328933034394305606610547548695572114475418861859185723418418335449088*x^2 + 698934161024097912313988531912594419543524661831111252286197385013781031639372622775 ....: 475026510556965115793039835522307708645909510694502414254723699140720599682877047132487963818434541534769581913895075840*x - 3450873173395281893717377931138512726225554486085193277581262111899648 ....: p.roots(AA, False) Traceback (most recent call last): ... RecursionError: maximum recursion depth exceeded
comment:9 Changed 2 years ago by
- Milestone changed from sage-9.1 to sage-9.2
Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity.
comment:10 Changed 19 months ago by
- Milestone changed from sage-9.2 to sage-9.3
comment:11 Changed 12 months ago by
- Milestone changed from sage-9.3 to sage-9.4
Moving to 9.4, as 9.3 has been released.
comment:12 Changed 9 months ago by
- Milestone changed from sage-9.4 to sage-9.5
comment:13 Changed 5 months ago by
- Milestone changed from sage-9.5 to sage-9.6
comment:14 Changed 2 weeks ago by
- Milestone changed from sage-9.6 to sage-9.7