# [Maxima] Simplifications of 3*sqrt(2)/sqrt(3)/sqrt(6)

Dieter Kaiser drdieterkaiser at web.de
Fri Jul 3 11:10:52 CDT 2009

```Am Donnerstag, den 02.07.2009, 20:35 -0400 schrieb Raymond Toy:
> Dieter Kaiser wrote:
>
> [nice examples snipped]
> > 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?
> Not sure.  The other examples you presented are probably what I would
> like.  But I'm not so sure that I would want sqrt(6) to be factored into
> sqrt(2)*sqrt(3).  But I would like sqrt(6)/sqrt(3) to be simplified to
> sqrt(2).  Perhaps these are conflicting desires on my part.

If we call the missing simplification of something like sqrt(6)/sqrt(3)
a bug we have to change something. I think this can be achieved in
general only if we factorize the integers, which are the base of a
power.

> And I think always calling factor for these cases may not be such a good
> idea.  What if the number is the product of two fairly large primes or
> even a prime?  Maxima will spend a lot of time trying to find the factors.

Yes, big prime numbers are a problem, when we factorize the wrong way.
My first choice was to use \$factor to get a quick success, but this will
not work in general. Today, I have done a lot of tests with prime
numbers and products of prime numbers and have found a better way to do
it.

The point is, that Maxima already does a partially factorization of
integers in the routine simpnrt. But this factorization is not
completely used.

Therefore, if we factorize in the routine TMS we extend the
factorization to more general powers of an integer. Unfortunately, we
partially repeat the the work of simpnrt. This can be avoided, when we
modify simpnrt to use the already calculated factorization completely.

This could be the code which factorize the integer with the method used
in simpnrt and does the desired simplification:

((and (mexptp factor)
(let ((\$factorflag t))
(setq tem (ratfact (cdr (ratrep* (cadr factor))) 'psqfr)))
(or (cddr tem)
(not (onep (cadr tem)))))
(let ((factors nil))
(do ((l tem (cddr l)))
((null l))
(if (onep (cadr l))
(push (car l) factors)
(push (list '(mexpt) (car l) (cadr l)) factors)))
(tms (cons '(mtimes) factors) (mul (caddr factor) power) product)))

Dieter Kaiser

```