From: SourceForge.net <noreply@so...>  20090525 16:54:11

Bugs item #826623, was opened at 20031020 06:25 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=826623&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  Simplification >Group: Includes proposed fix Status: Open Resolution: None Priority: 5 Private: No Submitted By: Stavros Macrakis (macrakis) Assigned to: Nobody/Anonymous (nobody) Summary: simplifer returns %i*%i Initial Comment: ((%i)^(1/2)*%i)*((%i)^(1/2)) => %i*%i Resimplifying  expand(%,0,0)  correctly returns 1. Maxima 5.9.0 gcl 2.5.0 mingw32 W2k Athlon  >Comment By: Dieter Kaiser (crategus) Date: 20090525 18:54 Message: I had a look at this bug. Here are some more general examples related to this report: (%i3) a*sqrt(a*b)*sqrt(a*b); (%o3) a*(a*b) (%i4) a*b*sqrt(a*b)*sqrt(a*b); (%o4) a*b*(a*b) Now with another exponent: (%i5) a*b*(a*b)^(1/4)*(a*b)^(3/4); (%o5) a*b*(a*b) Here is the example from this bug report: (%i6) %i*sqrt(%i)*sqrt(%i); (%o6) %i*%i This simplification error can be located to occur in the routine timesin in simp.lisp. This is the small piece of code which is responsible: ((onep1 w) (return (rplaca (cdr fm) (car x)))) When two factors are equal and the exonentents of the factors sum to 1, e. g. for sqrt(a*b)*sqrt(a*b) the factor is replaced by the base, that is for this example (a*b). Unfortunately, this is a mtimes expression. The simplifier generates a result with an unsimplified and nested mtimes expression in it. I have tried to find a better implementation and I have found the following code which works: ((onep1 w) (cond ((mtimesp (car x)) ;; A base which is a mtimes expression. ;; Remove the factor from the lists of products. (rplacd fm (cddr fm)) ;; We multiply the complete base with the list ;; of all remaining factors. (setq rulesw t) (return (muln (nconc y (cdar x)) t))) ;; The old code for the other cases. (t (return (rplaca (cdr fm) (car x)))))) Again the above examples with the modified code: (%i3) a*b*sqrt(a*b)*sqrt(a*b); (%o3) a^2*b^2 (%i4) a*sqrt(a*b)*sqrt(a*b); (%o4) a^2*b (%i5) a*b*sqrt(a*b)*sqrt(a*b); (%o5) a^2*b^2 (%i6) a*b*(a*b)^(1/4)*(a*b)^(3/4); (%o6) a^2*b^2 That is the example of this bug report: (%i7) %i*sqrt(%i)*sqrt(%i); (%o7) 1 The testsuite has no problems with the new code. Because this is a fundamental simplification error I supposed to get more problems with the testsuite. Perhaps a lot of examples do some extra expansions to get the desired simple result. The other inconsistencies reported in the bug report are not caused by this problem. I am not sure if the code above is the best way to remove this problem, but it works. Any comments? Dieter Kaiser  Comment By: Robert Dodier (robert_dodier) Date: 20060711 06:40 Message: Logged In: YES user_id=501686 Observed in 5.9.3cvs.  Comment By: Stavros Macrakis (macrakis) Date: 20031020 07:55 Message: Logged In: YES user_id=588346 This may be related to the inconsistent simplification of simple expressions involving %i: Mathematically, %i^(1/4) = (%i)^(1/4), but the first simplifies to (1)^(1/8) and the second to (%i)^(1/4) . Mathematically, (1)^(1/4) = %i^(1/2) = (%i)^(1/2), but the first two simplify to 1/(1)^(1/4), while the third simplifies to sqrt(%i). There are other similar cases. This is also reminiscent of the the nonnormalization of 1/sqrt(2)  bug # 721575.  You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=826623&group_id=4933 