Menu

#2838 factor() enters infinite loop.

None
open
nobody
factor (7)
5
2023-05-03
2014-11-06
No

Dear Developer of Maxima,

Every time when I use Maxima, I feel happiness of having such a nice system of symbolic computation as free software and also feel gratitude for your effort to develop Maxima. Thank you very much.

Recently, I met a possible bug of Maxima that factor() seems to enter infinite loop when a polynomial is given. Below, I report the bug. If you fix the bug, I become more happy to use Maxima.

My environment is described as

Maxima version: 5.34.1
LISP on which Maxma is built: SBCL 1.2.5
OS: MacOS X 10.10 (Yosemite)
Hardware: MacBook Pro

The demonstration is as follows:

Last login: Thu Nov  6 17:47:45 on ttys002
[wisdom4:~:1] adachi% cd work/570
[wisdom4:~/work/570:2] adachi% ls
./  bad_poly_for_factor.dat
../ demo_bad_poly_for_factor.mac
[wisdom4:~/work/570:3] adachi% cat bad_poly_for_factor.dat
;;; -*- Mode: LISP; package:maxima; syntax:common-lisp; -*- 
(in-package :maxima)
(DSKSETQ $N '$N) 
(ADD2LNC '$N $VALUES) 
(DSKSETQ $L '$L) 
(ADD2LNC '$L $VALUES) 
(DSKSETQ |$x|
         '((MPLUS SIMP) ((MTIMES SIMP) 1179869773824000. $L $N)
           ((MTIMES SIMP) -3206717492428800. ((MEXPT SIMP) $L 2.) $N)
           ((MTIMES SIMP) 3456620465356800. ((MEXPT SIMP) $L 3.) $N)
           ((MTIMES SIMP) -1968907685068800. ((MEXPT SIMP) $L 4.) $N)
           ((MTIMES SIMP) 656917077196800. ((MEXPT SIMP) $L 5.) $N)
           ((MTIMES SIMP) -132735349555200. ((MEXPT SIMP) $L 6.) $N)
           ((MTIMES SIMP) 15977403187200. ((MEXPT SIMP) $L 7.) $N)
           ((MTIMES SIMP) -1053455155200. ((MEXPT SIMP) $L 8.) $N)
           ((MTIMES SIMP) 29262643200. ((MEXPT SIMP) $L 9.) $N)
           ((MTIMES SIMP) 1179869773824000. ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) -9620152477286400. $L ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) 19270132784824320. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) -17767876470865920. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) 9164111740600320. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) -2875533138616320. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) 566653527982080. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) -69466588692480. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) 4936189870080. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) -159063367680. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 2.))
           ((MTIMES SIMP) -6413434984857600. ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) 31627024638935040. $L ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) -51382429032775680. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) 41570031208366080. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) -19619354213867520. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) 5821433911480320. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) -1119623844003840. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) 138224115671040. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) -10157272473600. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) 342918696960. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 3.))
           ((MTIMES SIMP) 15813512319467520. ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) -59305767078297600. $L ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) 82174120308080640. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) -59609511224524800. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) 26071364921978880. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) -7362135729930240. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) 1376351840747520. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) -167128361164800. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) 12043563356160. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) -390656286720. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 4.))
           ((MTIMES SIMP) -23722306831319040. ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) 73666925644677120. $L ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) -89955830574489600. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) 59602020231720960. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) -24418107272724480. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) 6568990806712320. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) -1176738671001600. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) 135675409121280. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) -9049472409600. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) 260681379840. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 5.))
           ((MTIMES SIMP) 24555641881559040. ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) -66112026084679680. $L ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) 72882744530964480. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) -44734066023628800. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) 17240212558356480. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) -4377384164966400. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) 731759701155840. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) -76660809523200. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) 4455968993280. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) -105345515520. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 6.))
           ((MTIMES SIMP) -18889150309908480. ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) 45441775246049280. $L ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) -46010894639431680. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) 26333891555328000. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) -9485962774364160. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) 2224278382878720. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) -334384223846400. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) 30250257408000. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) -1433869516800. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) 25360957440. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 7.))
           ((MTIMES SIMP) 11360443811512320. ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) -24922299688796160. $L ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) 23375249165721600. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) -12419461864857600. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) 4102751332270080. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) -859509671731200. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) 110991742525440. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) -8164277452800. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) 290118205440. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) -3344302080. ((MEXPT SIMP) $L 9.)
            ((MEXPT SIMP) $N 8.))
           ((MTIMES SIMP) -5538288819732480. ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) 11194517517926400. $L ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) -9696547832832000. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) 4700753500262400. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) -1381063614013440. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) 247644140728320. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) -25955964518400. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) 1433312133120. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) -33443020800. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) 185794560. ((MEXPT SIMP) $L 9.) ((MEXPT SIMP) $N 9.))
           ((MTIMES SIMP) 2238903503585280. ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) -4162000451051520. $L ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) 3276449709281280. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) -1407669209210880. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) 353031599370240. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) -51309118586880. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) 4040195604480. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) -147149291520. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) 1672151040. ((MEXPT SIMP) $L 8.)
            ((MEXPT SIMP) $N 10.))
           ((MTIMES SIMP) -756727354736640. ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) 1274344914124800. $L ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) -886514702008320. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) 324397859143680. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) -65858504785920. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) 7192757698560. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) -374561832960. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) 6688604160. ((MEXPT SIMP) $L 7.)
            ((MEXPT SIMP) $N 11.))
           ((MTIMES SIMP) 212390819020800. ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) -315287422894080. $L ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) 186442054041600. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) -55160082432000. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) 8413985341440. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) -608662978560. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) 15606743040. ((MEXPT SIMP) $L 6.)
            ((MEXPT SIMP) $N 12.))
           ((MTIMES SIMP) -48505757368320. ((MEXPT SIMP) $N 13.))
           ((MTIMES SIMP) 61096497315840. $L ((MEXPT SIMP) $N 13.))
           ((MTIMES SIMP) -29174855270400. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 13.))
           ((MTIMES SIMP) 6482650890240. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 13.))
           ((MTIMES SIMP) -655483207680. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 13.))
           ((MTIMES SIMP) 23410114560. ((MEXPT SIMP) $L 5.)
            ((MEXPT SIMP) $N 13.))
           ((MTIMES SIMP) 8728071045120. ((MEXPT SIMP) $N 14.))
           ((MTIMES SIMP) -8866580889600. $L ((MEXPT SIMP) $N 14.))
           ((MTIMES SIMP) 3177923051520. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 14.))
           ((MTIMES SIMP) -468202291200. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 14.))
           ((MTIMES SIMP) 23410114560. ((MEXPT SIMP) $L 4.)
            ((MEXPT SIMP) $N 14.))
           ((MTIMES SIMP) -1182210785280. ((MEXPT SIMP) $N 15.))
           ((MTIMES SIMP) 900732026880. $L ((MEXPT SIMP) $N 15.))
           ((MTIMES SIMP) -214035333120. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 15.))
           ((MTIMES SIMP) 15606743040. ((MEXPT SIMP) $L 3.)
            ((MEXPT SIMP) $N 15.))
           ((MTIMES SIMP) 112591503360. ((MEXPT SIMP) $N 16.))
           ((MTIMES SIMP) -56853135360. $L ((MEXPT SIMP) $N 16.))
           ((MTIMES SIMP) 6688604160. ((MEXPT SIMP) $L 2.)
            ((MEXPT SIMP) $N 16.))
           ((MTIMES SIMP) -6688604160. ((MEXPT SIMP) $N 17.))
           ((MTIMES SIMP) 1672151040. $L ((MEXPT SIMP) $N 17.))
           ((MTIMES SIMP) 185794560. ((MEXPT SIMP) $N 18.)))) 
(ADD2LNC '|$x| $VALUES)
[wisdom4:~/work/570:4] adachi% cat demo_bad_poly_for_factor.mac
loadfile("bad_poly_for_factor.dat");
display2d:false;
X;
factor(X);
quit();
[wisdom4:~/work/570:5] adachi% maxima -b demo_bad_poly_for_factor.mac
Maxima 5.34.1 http://maxima.sourceforge.net
using Lisp SBCL 1.2.5
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
STYLE-WARNING: redefining MAXIMA::ADD-LINEINFO in DEFUN
(%i1) batch("demo_bad_poly_for_factor.mac")

read and interpret file: /Ext/home/adachi/work/570/demo_bad_poly_for_factor.mac
(%i2) loadfile("bad_poly_for_factor.dat")
(%o2)                       bad_poly_for_factor.dat
(%i3) display2d:false
(%o3) false
(%i4) X
(%o4) 185794560*n^18+1672151040*l*n^17-6688604160*n^17+6688604160*l^2*n^16
                    -56853135360*l*n^16+112591503360*n^16+15606743040*l^3*n^15
                    -214035333120*l^2*n^15+900732026880*l*n^15
                    -1182210785280*n^15+23410114560*l^4*n^14
                    -468202291200*l^3*n^14+3177923051520*l^2*n^14
                    -8866580889600*l*n^14+8728071045120*n^14
                    +23410114560*l^5*n^13-655483207680*l^4*n^13
                    +6482650890240*l^3*n^13-29174855270400*l^2*n^13
                    +61096497315840*l*n^13-48505757368320*n^13
                    +15606743040*l^6*n^12-608662978560*l^5*n^12
                    +8413985341440*l^4*n^12-55160082432000*l^3*n^12
                    +186442054041600*l^2*n^12-315287422894080*l*n^12
                    +212390819020800*n^12+6688604160*l^7*n^11
                    -374561832960*l^6*n^11+7192757698560*l^5*n^11
                    -65858504785920*l^4*n^11+324397859143680*l^3*n^11
                    -886514702008320*l^2*n^11+1274344914124800*l*n^11
                    -756727354736640*n^11+1672151040*l^8*n^10
                    -147149291520*l^7*n^10+4040195604480*l^6*n^10
                    -51309118586880*l^5*n^10+353031599370240*l^4*n^10
                    -1407669209210880*l^3*n^10+3276449709281280*l^2*n^10
                    -4162000451051520*l*n^10+2238903503585280*n^10
                    +185794560*l^9*n^9-33443020800*l^8*n^9
                    +1433312133120*l^7*n^9-25955964518400*l^6*n^9
                    +247644140728320*l^5*n^9-1381063614013440*l^4*n^9
                    +4700753500262400*l^3*n^9-9696547832832000*l^2*n^9
                    +11194517517926400*l*n^9-5538288819732480*n^9
                    -3344302080*l^9*n^8+290118205440*l^8*n^8
                    -8164277452800*l^7*n^8+110991742525440*l^6*n^8
                    -859509671731200*l^5*n^8+4102751332270080*l^4*n^8
                    -12419461864857600*l^3*n^8+23375249165721600*l^2*n^8
                    -24922299688796160*l*n^8+11360443811512320*n^8
                    +25360957440*l^9*n^7-1433869516800*l^8*n^7
                    +30250257408000*l^7*n^7-334384223846400*l^6*n^7
                    +2224278382878720*l^5*n^7-9485962774364160*l^4*n^7
                    +26333891555328000*l^3*n^7-46010894639431680*l^2*n^7
                    +45441775246049280*l*n^7-18889150309908480*n^7
                    -105345515520*l^9*n^6+4455968993280*l^8*n^6
                    -76660809523200*l^7*n^6+731759701155840*l^6*n^6
                    -4377384164966400*l^5*n^6+17240212558356480*l^4*n^6
                    -44734066023628800*l^3*n^6+72882744530964480*l^2*n^6
                    -66112026084679680*l*n^6+24555641881559040*n^6
                    +260681379840*l^9*n^5-9049472409600*l^8*n^5
                    +135675409121280*l^7*n^5-1176738671001600*l^6*n^5
                    +6568990806712320*l^5*n^5-24418107272724480*l^4*n^5
                    +59602020231720960*l^3*n^5-89955830574489600*l^2*n^5
                    +73666925644677120*l*n^5-23722306831319040*n^5
                    -390656286720*l^9*n^4+12043563356160*l^8*n^4
                    -167128361164800*l^7*n^4+1376351840747520*l^6*n^4
                    -7362135729930240*l^5*n^4+26071364921978880*l^4*n^4
                    -59609511224524800*l^3*n^4+82174120308080640*l^2*n^4
                    -59305767078297600*l*n^4+15813512319467520*n^4
                    +342918696960*l^9*n^3-10157272473600*l^8*n^3
                    +138224115671040*l^7*n^3-1119623844003840*l^6*n^3
                    +5821433911480320*l^5*n^3-19619354213867520*l^4*n^3
                    +41570031208366080*l^3*n^3-51382429032775680*l^2*n^3
                    +31627024638935040*l*n^3-6413434984857600*n^3
                    -159063367680*l^9*n^2+4936189870080*l^8*n^2
                    -69466588692480*l^7*n^2+566653527982080*l^6*n^2
                    -2875533138616320*l^5*n^2+9164111740600320*l^4*n^2
                    -17767876470865920*l^3*n^2+19270132784824320*l^2*n^2
                    -9620152477286400*l*n^2+1179869773824000*n^2
                    +29262643200*l^9*n-1053455155200*l^8*n
                    +15977403187200*l^7*n-132735349555200*l^6*n
                    +656917077196800*l^5*n-1968907685068800*l^4*n
                    +3456620465356800*l^3*n-3206717492428800*l^2*n
                    +1179869773824000*l*n
(%i5) factor(X)

Here, factor() seems to enter an infinite loop and I have killed the process by sending the signal.

Remark:

(1) Last night, I left factor() to run on my computer. I slept. This morning, I found that factor() was still running.

(2) To split which side has the problem, Maxima or SBCL lisp, I also execute the same program "demo_bad_poly_for_factor.mac" by using another Maxima binary built on CMUCL Lisp. The observed phenomenon is the same: infinite loop.

Finally, in order to measure how heavy the factorization of the above polynomial is, I have written a small program by using GiNaC to factorize the same polynomial.

This is the demonstration:

Last login: Thu Nov  6 17:59:10 on ttys009
[wisdom4:~:1] adachi% cd work/571
[wisdom4:~/work/571:2] adachi% ls
./      bad_poly.txt
../     ginac_factor_bad_poly.C
[wisdom4:~/work/571:3] adachi% cat bad_poly.txt
185794560*n^18+1672151040*l*n^17-6688604160*n^17+6688604160*l^2*n^16
              -56853135360*l*n^16+112591503360*n^16+15606743040*l^3*n^15
              -214035333120*l^2*n^15+900732026880*l*n^15-1182210785280*n^15
              +23410114560*l^4*n^14-468202291200*l^3*n^14
              +3177923051520*l^2*n^14-8866580889600*l*n^14+8728071045120*n^14
              +23410114560*l^5*n^13-655483207680*l^4*n^13
              +6482650890240*l^3*n^13-29174855270400*l^2*n^13
              +61096497315840*l*n^13-48505757368320*n^13+15606743040*l^6*n^12
              -608662978560*l^5*n^12+8413985341440*l^4*n^12
              -55160082432000*l^3*n^12+186442054041600*l^2*n^12
              -315287422894080*l*n^12+212390819020800*n^12+6688604160*l^7*n^11
              -374561832960*l^6*n^11+7192757698560*l^5*n^11
              -65858504785920*l^4*n^11+324397859143680*l^3*n^11
              -886514702008320*l^2*n^11+1274344914124800*l*n^11
              -756727354736640*n^11+1672151040*l^8*n^10-147149291520*l^7*n^10
              +4040195604480*l^6*n^10-51309118586880*l^5*n^10
              +353031599370240*l^4*n^10-1407669209210880*l^3*n^10
              +3276449709281280*l^2*n^10-4162000451051520*l*n^10
              +2238903503585280*n^10+185794560*l^9*n^9-33443020800*l^8*n^9
              +1433312133120*l^7*n^9-25955964518400*l^6*n^9
              +247644140728320*l^5*n^9-1381063614013440*l^4*n^9
              +4700753500262400*l^3*n^9-9696547832832000*l^2*n^9
              +11194517517926400*l*n^9-5538288819732480*n^9-3344302080*l^9*n^8
              +290118205440*l^8*n^8-8164277452800*l^7*n^8
              +110991742525440*l^6*n^8-859509671731200*l^5*n^8
              +4102751332270080*l^4*n^8-12419461864857600*l^3*n^8
              +23375249165721600*l^2*n^8-24922299688796160*l*n^8
              +11360443811512320*n^8+25360957440*l^9*n^7-1433869516800*l^8*n^7
              +30250257408000*l^7*n^7-334384223846400*l^6*n^7
              +2224278382878720*l^5*n^7-9485962774364160*l^4*n^7
              +26333891555328000*l^3*n^7-46010894639431680*l^2*n^7
              +45441775246049280*l*n^7-18889150309908480*n^7
              -105345515520*l^9*n^6+4455968993280*l^8*n^6
              -76660809523200*l^7*n^6+731759701155840*l^6*n^6
              -4377384164966400*l^5*n^6+17240212558356480*l^4*n^6
              -44734066023628800*l^3*n^6+72882744530964480*l^2*n^6
              -66112026084679680*l*n^6+24555641881559040*n^6
              +260681379840*l^9*n^5-9049472409600*l^8*n^5
              +135675409121280*l^7*n^5-1176738671001600*l^6*n^5
              +6568990806712320*l^5*n^5-24418107272724480*l^4*n^5
              +59602020231720960*l^3*n^5-89955830574489600*l^2*n^5
              +73666925644677120*l*n^5-23722306831319040*n^5
              -390656286720*l^9*n^4+12043563356160*l^8*n^4
              -167128361164800*l^7*n^4+1376351840747520*l^6*n^4
              -7362135729930240*l^5*n^4+26071364921978880*l^4*n^4
              -59609511224524800*l^3*n^4+82174120308080640*l^2*n^4
              -59305767078297600*l*n^4+15813512319467520*n^4
              +342918696960*l^9*n^3-10157272473600*l^8*n^3
              +138224115671040*l^7*n^3-1119623844003840*l^6*n^3
              +5821433911480320*l^5*n^3-19619354213867520*l^4*n^3
              +41570031208366080*l^3*n^3-51382429032775680*l^2*n^3
              +31627024638935040*l*n^3-6413434984857600*n^3
              -159063367680*l^9*n^2+4936189870080*l^8*n^2
              -69466588692480*l^7*n^2+566653527982080*l^6*n^2
              -2875533138616320*l^5*n^2+9164111740600320*l^4*n^2
              -17767876470865920*l^3*n^2+19270132784824320*l^2*n^2
              -9620152477286400*l*n^2+1179869773824000*n^2+29262643200*l^9*n
              -1053455155200*l^8*n+15977403187200*l^7*n-132735349555200*l^6*n
              +656917077196800*l^5*n-1968907685068800*l^4*n
              +3456620465356800*l^3*n-3206717492428800*l^2*n
              +1179869773824000*l*n
[wisdom4:~/work/571:4] adachi% cat ginac_factor_bad_poly.C
//
//   ginac_factor_bad_poly.C:
//
//   S.Adachi 2014/11/05
//

#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
#include <ginac/ginac.h>

int main(int argc, char** argv)
{
  GiNaC::parser reader;
  std::ifstream ifs("bad_poly.txt");
  GiNaC::ex p = reader(ifs);

  std::cout << "[ ORIGINAL POLYNOMIAL ]" << std::endl;
  std::cout << p << std::endl;

  GiNaC::ex q = GiNaC::factor(p);

  std::cout << "[ FACTORIZED POLYNOMIAL ]" << std::endl;
  std::cout << q << std::endl;

  return 0;
}

///////////////////////////////////////////////////////////////////////////////
//   END                                                                     //
///////////////////////////////////////////////////////////////////////////////
[wisdom4:~/work/571:5] adachi% g++ ginac_factor_bad_poly.C -lginac -lgmp
[wisdom4:~/work/571:6] adachi% ls
./      bad_poly.txt
../     ginac_factor_bad_poly.C
a.out*
[wisdom4:~/work/571:7] adachi% /usr/bin/time ./a.out
[ ORIGINAL POLYNOMIAL ]
3276449709281280*n^10*l^2-8164277452800*n^8*l^7-6688604160*n^17-18889150309908480*n^7+656917077196800*n*l^5-4377384164966400*n^6*l^5+185794560*n^9*l^9-334384223846400*n^7*l^6-55160082432000*n^12*l^3+31627024638935040*n^3*l-17767876470865920*n^2*l^3-9696547832832000*n^9*l^2-1968907685068800*n*l^4+17240212558356480*n^6*l^4+30250257408000*n^7*l^7+24555641881559040*n^6+110991742525440*n^8*l^6-10157272473600*n^3*l^8+324397859143680*n^11*l^3+19270132784824320*n^2*l^2+186442054041600*n^12*l^2+61096497315840*n^13*l-23722306831319040*n^5+15977403187200*n*l^7-76660809523200*n^6*l^7-9485962774364160*n^7*l^4-8866580889600*n^14*l-1407669209210880*n^10*l^3-859509671731200*n^8*l^5-886514702008320*n^11*l^2+731759701155840*n^6*l^6-132735349555200*n*l^6+900732026880*n^15*l+15813512319467520*n^4-159063367680*n^2*l^9+2224278382878720*n^7*l^5+4700753500262400*n^9*l^3+4102751332270080*n^8*l^4-56853135360*n^16*l-7362135729930240*n^4*l^5+1274344914124800*n^11*l+4936189870080*n^2*l^8+185794560*n^18-214035333120*n^15*l^2+6688604160*n^16*l^2+135675409121280*n^5*l^7-1176738671001600*n^5*l^6-9620152477286400*n^2*l+26071364921978880*n^4*l^4+8728071045120*n^14+41570031208366080*n^3*l^3-29174855270400*n^13*l^2-315287422894080*n^12*l+3177923051520*n^14*l^2+342918696960*n^3*l^9+11194517517926400*n^9*l+6568990806712320*n^5*l^5+1672151040*n^10*l^8+15606743040*n^15*l^3+212390819020800*n^12-167128361164800*n^4*l^7-4162000451051520*n^10*l+1376351840747520*n^4*l^6-24418107272724480*n^5*l^4-468202291200*n^14*l^3-33443020800*n^9*l^8+2238903503585280*n^10-51382429032775680*n^3*l^2+6482650890240*n^13*l^3+82174120308080640*n^4*l^2-655483207680*n^13*l^4+1672151040*n^17*l+45441775246049280*n^7*l+23410114560*n^14*l^4+290118205440*n^8*l^8-1119623844003840*n^3*l^6+11360443811512320*n^8+59602020231720960*n^5*l^3+138224115671040*n^3*l^7+23410114560*n^13*l^5-390656286720*n^4*l^9-24922299688796160*n^8*l-1433869516800*n^7*l^8+4455968993280*n^6*l^8-89955830574489600*n^5*l^2-1053455155200*n*l^8-19619354213867520*n^3*l^4-59609511224524800*n^4*l^3-66112026084679680*n^6*l+1179869773824000*n*l+5821433911480320*n^3*l^5+260681379840*n^5*l^9-374561832960*n^11*l^6-1381063614013440*n^9*l^4-12419461864857600*n^8*l^3-51309118586880*n^10*l^5-9049472409600*n^5*l^8-3206717492428800*n*l^2-6413434984857600*n^3+72882744530964480*n^6*l^2-69466588692480*n^2*l^7+73666925644677120*n^5*l+566653527982080*n^2*l^6+247644140728320*n^9*l^5+353031599370240*n^10*l^4-48505757368320*n^13+26333891555328000*n^7*l^3+15606743040*n^12*l^6-1182210785280*n^15+29262643200*n*l^9+6688604160*n^11*l^7-105345515520*n^6*l^9+112591503360*n^16-756727354736640*n^11+25360957440*n^7*l^9-25955964518400*n^9*l^6-65858504785920*n^11*l^4-2875533138616320*n^2*l^5-608662978560*n^12*l^5+12043563356160*n^4*l^8+1179869773824000*n^2+3456620465356800*n*l^3-44734066023628800*n^6*l^3-147149291520*n^10*l^7+23375249165721600*n^8*l^2-5538288819732480*n^9+4040195604480*n^10*l^6+9164111740600320*n^2*l^4+7192757698560*n^11*l^5-59305767078297600*n^4*l+8413985341440*n^12*l^4-3344302080*n^8*l^9-46010894639431680*n^7*l^2+1433312133120*n^9*l^7
[ FACTORIZED POLYNOMIAL ]
-11612160*(-3+n+l)*(-4+n)*(n+l)*(-176400+256*n^7-55168*n^3*l-26355*l^2+5240*n^2*l^3+352*n*l^4-1856*n^6-33376*n^2*l^2+2730*l^3+8368*n^5-27584*n^4+108816*n^2*l-16*n^4*l^4-2544*n^3*l^3+17440*n^3*l^2-5912*n^4*l^2-64*n^7*l-16*n^8-64*n^5*l^3+223860*n+1152*n^5*l^2+128*n^3*l^4+640*n^4*l^3+896*n^6*l-151372*n*l+41732*n*l^2+72544*n^3-96*n^6*l^2-5568*n^5*l-105*l^4-151372*n^2+111930*l-5792*n*l^3-344*n^2*l^4+20920*n^4*l)*(-2+n+l)*(-2+n)*(-3+n)*(-4+n+l)*n*(-1+n)*(-1+n+l)
        0.59 real         0.30 user         0.00 sys
[wisdom4:~/work/571:8] adachi% 

Namely, the polynomial is factorized within 1 sec by GiNaC. Hence, the factorization of this polynomial is not heavy.

This means that the factor() in Maxima when the same polynomial is given as the angument perhaps falls into an infinite loop.

If you fix this bug, Maxima slightly gets close to complete and every user of Maxima in the world becomes more happy.

Thank you very much in advance.

Sincerely yours,

Satoshi Adachi

Discussion

  • Robert Dodier

    Robert Dodier - 2023-05-03
    • labels: factor() enters infinite loop. --> factor
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,14 +1,8 @@
     Dear Developer of Maxima,
    
    -Every time when I use Maxima, I feel happiness of having
    -such a nice system of symbolic computation as freesoftware
    -and also feel gratitude for your effort to develop Maxima.
    -Thank you very much.
    -
    -Recently, I met a possible bug of Maxima that factor() seems to
    -enter infinite loop when a polynomial is given.
    -Below, I report the bug. If you fix the bug, I become more happy
    -to use Maxima.
    +Every time when I use Maxima, I feel happiness of having such a nice system of symbolic computation as free software and also feel gratitude for your effort to develop Maxima. Thank you very much.
    +
    +Recently, I met a possible bug of Maxima that factor() seems to enter infinite loop when a polynomial is given. Below, I report the bug. If you fix the bug, I become more happy to use Maxima.
    
     My environment is described as
    
    @@ -18,7 +12,8 @@
     Hardware: MacBook Pro
    
     The demonstration is as follows:
    --------------------------------------------------------------------------------
    +
    +```
     Last login: Thu Nov  6 17:47:45 on ttys002
     [wisdom4:~:1] adachi% cd work/570
     [wisdom4:~/work/570:2] adachi% ls
    @@ -258,6 +253,9 @@
                ((MTIMES SIMP) 1672151040. $L ((MEXPT SIMP) $N 17.))
                ((MTIMES SIMP) 185794560. ((MEXPT SIMP) $N 18.)))) 
     (ADD2LNC &#39;|$x| $VALUES)
    +```
    +
    +```
     [wisdom4:~/work/570:4] adachi% cat demo_bad_poly_for_factor.mac
     loadfile(&#34;bad_poly_for_factor.dat&#34;);
     display2d:false;
    @@ -346,28 +344,21 @@
                         +3456620465356800*l^3*n-3206717492428800*l^2*n
                         +1179869773824000*l*n
     (%i5) factor(X)
    --------------------------------------------------------------------------------
    -
    -Here, factor() seems to enter an infinite loop and I have killed
    -the process by sending the signal.
    +```
    +
    +Here, factor() seems to enter an infinite loop and I have killed the process by sending the signal.
    
     Remark:
    
    -(1) Last night, I left factor() to run on my computer. I slept.
    -This morning, I found that factor() was still running.
    -
    -(2) To split which side has the problem, Maxima or SBCL lisp,
    -I also execute the same program &#34;demo_bad_poly_for_factor.mac&#34; by using
    -another Maxima binary built on CMUCL Lisp. The observed phenomenon is
    -the same: infinite loop.
    -
    -
    -Finnaly, in order to measure how heavy the factorization of the above
    -polynomial is, I have written a small program by using GiNaC to factorize
    -the same polynomial.
    +(1) Last night, I left factor() to run on my computer. I slept. This morning, I found that factor() was still running.
    +
    +(2) To split which side has the problem, Maxima or SBCL lisp, I also execute the same program &#34;demo_bad_poly_for_factor.mac&#34; by using another Maxima binary built on CMUCL Lisp. The observed phenomenon is the same: infinite loop.
    +
    +
    +Finally, in order to measure how heavy the factorization of the above polynomial is, I have written a small program by using GiNaC to factorize the same polynomial.
    
     This is the demonstration:
    --------------------------------------------------------------------------------
    +```
     Last login: Thu Nov  6 17:59:10 on ttys009
     [wisdom4:~:1] adachi% cd work/571
     [wisdom4:~/work/571:2] adachi% ls
    @@ -435,7 +426,9 @@
                   +656917077196800*l^5*n-1968907685068800*l^4*n
                   +3456620465356800*l^3*n-3206717492428800*l^2*n
                   +1179869773824000*l*n
    -  
    +```
    +
    +```
     [wisdom4:~/work/571:4] adachi% cat ginac_factor_bad_poly.C
     //
     //   ginac_factor_bad_poly.C:
    @@ -481,16 +474,13 @@
     -11612160*(-3+n+l)*(-4+n)*(n+l)*(-176400+256*n^7-55168*n^3*l-26355*l^2+5240*n^2*l^3+352*n*l^4-1856*n^6-33376*n^2*l^2+2730*l^3+8368*n^5-27584*n^4+108816*n^2*l-16*n^4*l^4-2544*n^3*l^3+17440*n^3*l^2-5912*n^4*l^2-64*n^7*l-16*n^8-64*n^5*l^3+223860*n+1152*n^5*l^2+128*n^3*l^4+640*n^4*l^3+896*n^6*l-151372*n*l+41732*n*l^2+72544*n^3-96*n^6*l^2-5568*n^5*l-105*l^4-151372*n^2+111930*l-5792*n*l^3-344*n^2*l^4+20920*n^4*l)*(-2+n+l)*(-2+n)*(-3+n)*(-4+n+l)*n*(-1+n)*(-1+n+l)
             0.59 real         0.30 user         0.00 sys
     [wisdom4:~/work/571:8] adachi% 
    --------------------------------------------------------------------------------
    -
    -Namely, the polynomial is factorized within 1 sec by GiNaC.
    -Hence, the factorization of this polynomial is not heavy.
    -
    -This means that the factor() in Maxima when the same polynomial is given
    -as the angument perhaps falls into an infinite loop.
    -
    -If you fix this bug, Maxima slightly gets close to complete
    -and every user of Maxima in the world becomes more happy.
    +```
    +
    +Namely, the polynomial is factorized within 1 sec by GiNaC. Hence, the factorization of this polynomial is not heavy.
    +
    +This means that the factor() in Maxima when the same polynomial is given as the angument perhaps falls into an infinite loop.
    +
    +If you fix this bug, Maxima slightly gets close to complete and every user of Maxima in the world becomes more happy.
    
     Thank you very much in advance.
    
     
  • Stavros Macrakis

    Interestingly (?), if we call the original polynomial pp, then factor(pp/((n+l)*((n+l-1)))) takes only 13ms.

     

Log in to post a comment.