Subject: Simplifications of 3*sqrt(2)/sqrt(3)/sqrt(6)
From: Dieter Kaiser
Date: Fri, 03 Jul 2009 00:05:54 +0200
I had a look at the bug report ID: 1639678 "3*sqrt(2)/sqrt(3)/sqrt(6) !=
1". Because I have done some work on TMS and TIMESIN I have tried to
optimize the algorithm to simplify such expressions.
First my results.
This is the example of the bug report. It simplifies immediately:
(%i1) 3*sqrt(2)/sqrt(3)/sqrt(6);
(%o1) 1
Other examples are:
(%i3) sqrt(6)/sqrt(12);
(%o3) 1/sqrt(2)
(%i4) sqrt(6)/sqrt(10);
(%o4) sqrt(3)/sqrt(5)
Furthermore the following example simplifies nicely:
(%i5) 4^(1/4)*4^(n/2);
(%o5) 2^(n+1/2)
With the CVS code we have the result sqrt(2)*4^(n/2).
This is a result for big numbers we have now;
(%i7) sqrt(101!)/sqrt(100!);
(%o7) sqrt(31450696910808591132148340194) /
sqrt(311393038720877139922260794)
And this is the result we would get:
(%i11) sqrt(101!)/sqrt(100!);
(%o11) sqrt(101)
I have run the testsuite and the share_testsuite and got no problems.
Only some examples are better simplified.
To achieve these simplifications I have added the following code to TMS:
((and (mexptp factor)
(integerp (cadr factor))
(not (atom (setq tem ($factor (cadr factor))))))
(tms tem (mul (caddr factor) power) product))
The idea is to factor an integer which is the base of a mexpt-expression
and multiply the factored form into the list of products. I do not know
if this method is the fastest way to get the factors of an integer. But
the code is only called a few times within the testsuite and
share_testsuite and therefore the much better simplified results might
overweight the effort to get the factors.
One change of the behavior of Maxima is, that we always get more
factored results, e.g.
(%i6) sqrt(6);
(%o6) sqrt(2)*sqrt(3)
(%i14) sqrt(10);
(%o14) sqrt(2)*sqrt(5)
and no longer sqrt(6) or sqrt(10).
Any comments?
Dieter Kaiser