From: SourceForge.net <no...@so...> - 2007-12-14 11:05:08
|
Bugs item #1845363, was opened at 2007-12-06 02:57 Message generated for change (Comment added) made by willisbl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1845363&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Polynomials Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Satoshi Adachi (satoshi_adachi) Assigned to: Nobody/Anonymous (nobody) Summary: a bug in ratsimp()? Initial Comment: ratsimp() in Maxima-5.13.0 returns a strange result. cat maxima-5.13.0-bug-essence.maxima tmp:n^2/(n^2+sqrt(5)*n+2*n+sqrt(5)) + sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5)) - 1/(n^2+sqrt(5)*n+2*n+sqrt(5)); Maxima 5.13.0 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) batch(maxima-5.13.0-bug-essence.maxima) batching #p/Volumes/HFS+2/home/adachi/work/269/maxima-5.13.0-bug-essence.maxima - 1 sqrt(5) n (%i2) tmp : ------------------------------ + ------------------------------ 2 2 sqrt(5) + 2 n + sqrt(5) n + n sqrt(5) + 2 n + sqrt(5) n + n 2 n + ------------------------------ 2 sqrt(5) + 2 n + sqrt(5) n + n 2 n sqrt(5) n (%o2) ------------------------------ + ------------------------------ 2 2 n + sqrt(5) n + 2 n + sqrt(5) n + sqrt(5) n + 2 n + sqrt(5) 1 - ------------------------------ 2 n + sqrt(5) n + 2 n + sqrt(5) (%i3) tmp : ratsimp(tmp) 6 5 4 3 (%o3) (n + (3 sqrt(5) + 4) n + (10 sqrt(5) + 18) n + (11 sqrt(5) + 36) n 2 + (4 sqrt(5) + 16) n + (sqrt(5) - 10) n - 5) 6 5 4 3 /(n + (3 sqrt(5) + 6) n + (15 sqrt(5) + 27) n + (29 sqrt(5) + 68) n 2 + (27 sqrt(5) + 75) n + (15 sqrt(5) + 30) n + 5 sqrt(5)) =========================================== The following is the result obtained by maxima-5.9.2: Maxima 5.9.2 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) batch(maxima-5.13.0-bug-essence.maxima) batching #p/Volumes/HFS+2/home/adachi/work/269/maxima-5.13.0-bug-essence.maxima - 1 sqrt(5) n (%i2) tmp : ------------------------------ + ------------------------------ 2 2 sqrt(5) + 2 n + sqrt(5) n + n sqrt(5) + 2 n + sqrt(5) n + n 2 n + ------------------------------ 2 sqrt(5) + 2 n + sqrt(5) n + n 2 n sqrt(5) n (%o2) ------------------------------ + ------------------------------ 2 2 n + sqrt(5) n + 2 n + sqrt(5) n + sqrt(5) n + 2 n + sqrt(5) 1 - ------------------------------ 2 n + sqrt(5) n + 2 n + sqrt(5) (%i3) tmp : ratsimp(tmp) 2 n + sqrt(5) n - 1 (%o3) ------------------------------ 2 n + (sqrt(5) + 2) n + sqrt(5) ---------------------------------------------------------------------- >Comment By: Barton Willis (willisbl) Date: 2007-12-14 05:05 Message: Logged In: YES user_id=895922 Originator: NO Thanks for the clarification. I don't know the answers to your questions. We changed the default gcd algorithm to spmod sometime ago because spmod seamed to have fewer bugs. Recently, some of these subres bug have been fixed. So it might be time to re-visit the default gcd algorithm. Again, thanks for the bug report and clarification. ---------------------------------------------------------------------- Comment By: Satoshi Adachi (satoshi_adachi) Date: 2007-12-14 02:01 Message: Logged In: YES user_id=1953419 Originator: YES Dear Developers of Maxima, I here elucidate what I wanted to say in my previous ``bug'' report entitled ``a bug in ratsimp()?''. In addition, I have found that the phenomenon that I reported in the previous email may be not a bug but is caused by the change of the default GCD algorithm in Maxima from ``subres'' to ``spmod''. I will also explain this point. At first, I want to say I am sorry that I sent a ``disordered'' bug report in appearence. I did not expect such an appearence. I might cause the Maxima developers to spend some unnecessary efforts to read my previous report. I use "display2d:false" below as was suggested by Mr.willisbl. I use the following test program: ------------------------------------------------------------------------------- [wisdom3:~/work/269:1] adachi% cat maxima-ratsimp-test-essence.maxima display2d:false; X:n^2/(n^2+sqrt(5)*n+2*n+sqrt(5)) + sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5)) - 1/(n^2+sqrt(5)*n+2*n+sqrt(5)); X_expected_to_be_simple:ratsimp(X); difference:ratsimp(X-X_expected_to_be_simple); ------------------------------------------------------------------------------- The execution of the test program by maxima-5.13.0 results in ------------------------------------------------------------------------------- [wisdom3:~/work/269:2] adachi% maxima -b maxima-ratsimp-test-essence.maxima Maxima 5.13.0 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) batch(maxima-ratsimp-test-essence.maxima) batching #p/Volumes/HFS+2/home/adachi/work/269/maxima-ratsimp-test-essence.maxima (%i2) display2d : false (%o2) false (%i3) X:(-1)/(sqrt(5)+2*n+sqrt(5)*n+n^2)+sqrt(5)*n/(sqrt(5)+2*n+sqrt(5)*n+n^2) +n^2/(sqrt(5)+2*n+sqrt(5)*n+n^2) (%o3) n^2/(n^2+sqrt(5)*n+2*n+sqrt(5))+sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5)) -1/(n^2+sqrt(5)*n+2*n+sqrt(5)) (%i4) X_expected_to_be_simple:ratsimp(X) (%o4) (n^6+(3*sqrt(5)+4)*n^5+(10*sqrt(5)+18)*n^4+(11*sqrt(5)+36)*n^3 +(4*sqrt(5)+16)*n^2+(sqrt(5)-10)*n-5) /(n^6+(3*sqrt(5)+6)*n^5+(15*sqrt(5)+27)*n^4+(29*sqrt(5)+68)*n^3 +(27*sqrt(5)+75)*n^2+(15*sqrt(5)+30)*n+5*sqrt(5)) (%i5) difference:ratsimp(X-X_expected_to_be_simple) (%o5) 0 ------------------------------------------------------------------------------ As is seen at (%o4), ratsimp() returns a rather complicated expression, although the routine is expected to simplify any rational function that is given to the routine. It is noted that the comlicated expression is correct in value as is seen at (%o5). To compare, I use maxima-5.9.2 to execute the same test program. The result is the following: ------------------------------------------------------------------------------- [wisdom3:~/work/269:3] adachi% maxima -u 5.9.2 -b maxima-ratsimp-test-essence.maxima Maxima 5.9.2 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) batch(maxima-ratsimp-test-essence.maxima) batching #p/Volumes/HFS+2/home/adachi/work/269/maxima-ratsimp-test-essence.maxima (%i2) display2d : false (%o2) false (%i3) X:(-1)/(sqrt(5)+2*n+sqrt(5)*n+n^2)+sqrt(5)*n/(sqrt(5)+2*n+sqrt(5)*n+n^2) +n^2/(sqrt(5)+2*n+sqrt(5)*n+n^2) (%o3) n^2/(n^2+sqrt(5)*n+2*n+sqrt(5))+sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5)) -1/(n^2+sqrt(5)*n+2*n+sqrt(5)) (%i4) X_expected_to_be_simple:ratsimp(X) (%o4) (n^2+sqrt(5)*n-1)/(n^2+(sqrt(5)+2)*n+sqrt(5)) (%i5) difference:ratsimp(X-X_expected_to_be_simple) (%o5) 0 ------------------------------------------------------------------------------- Clearly, ratsimp() returns a simple expression as is seen at (%o4). This is the result that I expected to maxima to return. The result obtained by maxima-5.13.0 is unnecessarily complicated and is not what I want maxima to return. After I posted the previous report, I found that the behavior of maxima-5.13.0 that I am reporting here seems to be realted with a change of the default GCD algorithm in Maxima. The default GCD algorithm used to be "subres" in maxima-5.9.2 as ------------------------------------------------------------------------------- [wisdom3:~/work/269:4] adachi% maxima -u 5.9.2 --batch-string="gcd;" Maxima 5.9.2 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) gcd (%o1) subres ------------------------------------------------------------------------------- while it is now "spmod" in maxima-5.13.0 as ------------------------------------------------------------------------------- [wisdom3:~/work/269:5] adachi% maxima --batch-string="gcd;" Maxima 5.13.0 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) gcd (%o1) spmod ------------------------------------------------------------------------------- I know nothing about what "subres" and "spmod" mean and what is the main difference of them about which I have to be careful when writing programs. (What is the merit and the demerit of the new default algorithm "spmod"?) Anyway, if the GCD algorithm in maxima-5.13.0 is changed to "subres" by "gcd:subres;", maxima-5.13.0 gives me the expected result when it is invoked to the same test program as ------------------------------------------------------------------------------- [wisdom3:~/work/269:6] adachi% cat maxima-ratsimp-test-essence-subres.maxima display2d:false; gcd:subres; X:n^2/(n^2+sqrt(5)*n+2*n+sqrt(5)) + sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5)) - 1/(n^2+sqrt(5)*n+2*n+sqrt(5)); X_expected_to_be_simple:ratsimp(X); difference:ratsimp(X-X_expected_to_be_simple); [wisdom3:~/work/269:7] adachi% maxima -b maxima-ratsimp-test-essence-subres.maxima Maxima 5.13.0 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) batch(maxima-ratsimp-test-essence-subres.maxima) batching #p/Volumes/HFS+2/home/adachi/work/269/maxima-ratsimp-test-essence-subres.maxima (%i2) display2d : false (%o2) false (%i3) gcd:subres (%o3) subres (%i4) X:(-1)/(sqrt(5)+2*n+sqrt(5)*n+n^2)+sqrt(5)*n/(sqrt(5)+2*n+sqrt(5)*n+n^2) +n^2/(sqrt(5)+2*n+sqrt(5)*n+n^2) (%o4) n^2/(n^2+sqrt(5)*n+2*n+sqrt(5))+sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5)) -1/(n^2+sqrt(5)*n+2*n+sqrt(5)) (%i5) X_expected_to_be_simple:ratsimp(X) (%o5) (n^2+sqrt(5)*n-1)/(n^2+(sqrt(5)+2)*n+sqrt(5)) (%i6) difference:ratsimp(X-X_expected_to_be_simple) (%o6) 0 ------------------------------------------------------------------------------- This (%o5) is the expected result. I do not known whether the phenomenon that I have reported in this email is a ``specification'' of the GCD algorithm "spmod" or is a bug of "spmod". Finally, I want to say Maxima developers thank you very much for your efforts to develop Maxima. I have been very happy to use maxima. Sincerely yours, Satoshi Adachi P.S. In documentation of maxima-5.13.0, the default GCD algorithm is still described as to be "subres" as ------------------------------------------------------------------------------- [wisdom3:~/work/269:7] adachi% maxima --batch-string="? gcd;" Maxima 5.13.0 http://maxima.sourceforge.net Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) describe(gcd, exact) -- Function: gcd (<p_1>, <p_2>, <x_1>, ...) Returns the greatest common divisor of <p_1> and <p_2>. The flag `gcd' determines which algorithm is employed. Setting `gcd' to `ez', `subres', `red', or `spmod' selects the `ezgcd', subresultant `prs', reduced, or modular algorithm, respectively. If `gcd' `false' then `gcd (<p_1>, <p_2>, <x>)' always returns 1 for all <x>. Many functions (e.g. `ratsimp', `factor', etc.) cause gcd's to be taken implicitly. For homogeneous polynomials it is recommended that `gcd' equal to `subres' be used. To take the gcd when an algebraic is present, e.g., `gcd (<x>^2 - 2*sqrt(2)*<x> + 2, <x> - sqrt(2))', `algebraic' must be `true' and `gcd' must not be `ez'. `subres' is a new algorithm, and people who have been using the `red' setting should probably change it to `subres'. The `gcd' flag, default: `subres', if `false' will also prevent the greatest common divisor from being taken when expressions are converted to canonical rational expression (CRE) form. This will sometimes speed the calculation if gcds are not required. There are also some inexact matches for `gcd'. Try `?? gcd' to see them. (%o1) true ------------------------------------------------------------------------------- It is better to change the documentation to match the reality. ---------------------------------------------------------------------- Comment By: Barton Willis (willisbl) Date: 2007-12-11 18:51 Message: Logged In: YES user_id=895922 Originator: NO What is strange about the following: (%i4) tmp:n^2/(n^2+sqrt(5)*n+2*n+sqrt(5)) + sqrt(5)*n/(n^2+sqrt(5)*n+2*n+sqrt(5))$ (%i5) tmp - ratsimp(tmp)$ (%i6) ratsimp(%); (%o6) 0 Try display2d : false and re-posting. It's hard to read your bug report. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1845363&group_id=4933 |