((-%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
Stavros Macrakis
2003-10-20
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 non-normalization of 1/sqrt(2) -- bug # 721575.
Robert Dodier
2006-07-11
Logged In: YES
user_id=501686
Observed in 5.9.3cvs.
Robert Dodier
2006-07-11
Robert Dodier
2006-09-09
Dieter Kaiser
2009-05-25
Dieter Kaiser
2009-05-25
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
Dieter Kaiser
2009-05-28
Dieter Kaiser
2009-05-28
Suggested test for a base which is a mtimes expressions in expressions like (a*b)^q*(a*b)^q, where q+r=1 has been checked out.
The example of this bug report now simplifies:
(%i6) sqrt(-%i)*sqrt(-%i)*%i;
(%o6) 1
Other examples are:
(%i7) sqrt(a*b)*sqrt(a*b)*a*b;
(%o7) a^2*b^2
(%i8) (a*b*x)^(1/5)*(a*b*x)^(4/5)*x;
(%o8) a*b*x^2
The initial example simplifies correctly. Closing this bug report as fixed.
Dieter Kaiser