simplification of radicals



On Fri, Jul 25, 2008 at 4:04 PM, Barton Willis <willisb at unk.edu> wrote:
> A few versions ago, I think the following simplified to zero; now it doesn't:
>
>  (%i6) sqrt(3) * sqrt(17) - sqrt(51);

I don't think Maxima ever did this. If Maxima *were* to do this in the
general simplifier (G.S.), it would do it by having a canonical form
for expressions like this.

That is, the forms sqrt(120), 2*sqrt(30), 2*sqrt(5)*sqrt(6),
2*sqrt(2)*sqrt(15), and 2*sqrt(2)*sqrt(3)*sqrt(5) would all have to
simplify to the same thing, presumably either sqrt(120) (fully
multiplied out), 2*sqrt(30) (remove exact roots), or
2*sqrt(2)*sqrt(3)*sqrt(5) (fully factored).

Any of these would be easy enough to implement -- since Maxima already
factors numbers taken to fractional powers for the sqrt(120) =>
2*sqrt(30) case -- but I'm not convinced they're a better user
experience than the current system.

You might think that you could do this using scanmap(factor,
sqrt(51)), since sqrt(factor(51)) => sqrt(3)*sqrt(17), but this
doesn't work.  Why not?  Because there is a special case in factor
*explicitly blocking* it within scanmap: if factor is called directly
or indirectly within scanmap, it does not factor integers.  This is so
that scanmap(factor, f(240*x-6) ) will return f(6*(40*x-1)) rather
than f(2*3*(2^3*5*x-1)), which seems like the right thing in
general... though it is unfortunate that it messes up this case.  The
root cause of the problem here is the decision to make polynomial
factorization and integer factorization both use the name "factor"
rather than distinguishing them, which is a reasonable decision for
intuitive ease of use, though not for rigor....

So the only workaround I can see is to write your own scanfactorpower, e.g.

scanfactorpower(ex):=block([inflag:true],
   if mapatom(ex) then ex
   elseif op(ex)="^" and ratnump(part(ex,1)) and ratnump(part(ex,2))
      then block([algebraic:true],ratsimp(factor(part(ex,1)) ^ part(ex,2)))
     else map(scanfactorpower,ex) ) $

scanfactorpower( sqrt(30)/sqrt(35) ) => sqrt(2)*sqrt(3)/sqrt(7)   /*
GCD not done in G.S. */
scanfactorpower( sqrt(210) ) => sqrt(2)*sqrt(3)*sqrt(5)*sqrt(7)
scanfactorpower( sqrt(2/3)-sqrt(6)/3 ) => 0            /* reason for
ratsimp/algebraic */

Does this solve your problem?

             -s