square root expression simplification



On Oct. 31, 2010, Dieter Kaiser wrote:
--------------------------------------------------------
> I have three questions about the square root function:
> 1. Is it the desired behavior of Maxima to return the principal square 
> root
> for numbers?
> sqrt(4)  -> 2
> sqrt(-4) -> 2*%i
> This is the implementation we have for real and complex numbers.
--------------------------------------
I would like principal value definitions to be returned for
multiple-valued functions (as in Mathematica and
Macsyma), so that the Log principal value def.

  Log(zz) := log (abs(zz)) + %i*carg (zz)$

   for z = r*exp(%i*theta), r = abs(z) > 0 ,
   theta = carg(z),
  and  - %pi < theta <= %pi .

The combination of rectform and Maxima's log(z)
is equivalent to this definition, which involves
a branch cut along the negative real(z) axis.

The standard complex analysis definition
  of the principle value of a power is

  z^z1 = exp (z1*Log(z))

  where again Log(z) is the choice made
  for the principal value log function.

This then provides the  principal value square
root function  defined in terms of the
principal value  log function Log :

psqrt(zz) := exp (Log (zz)/2)$

The combination of rectform and sqrt
is equivalent to this principal value
square root definition.

Likewise the principal value definition of the
expression
  (-1)^(1/8)  would be

exp ( Log  (-1)/8 )

which is what rectform ( (-1)^(1/8) )
returns.

With the above Log and psqrt defs in place,
and using some point zj on the unit circle:

(%i2) zlist;
(%o2) [-1,%i,1,-%i]

/*  principal value of log */

(%i3) log(zlist);
(%o3) [log(-1),log(%i),0,log(-%i)]
(%i4) rectform(%);
(%o4) [%i*%pi,%i*%pi/2,0,-%i*%pi/2]

(%i5) map ('Log,zlist);
(%o5) [%i*%pi,%i*%pi/2,0,-%i*%pi/2]

(%i6) map ('plog,zlist);
(%o6) [%i*%pi,%i*%pi/2,0,-%i*%pi/2]

(%i7) z5;
(%o7) %e^-(9*%i*%pi/10)

(%i8) log(z5);
(%o8) -9*%i*%pi/10

(%i9) Log(z5);
(%o9) -9*%i*%pi/10

(%i10) plog(z5);
(%o10) plog(%e^-(9*%i*%pi/10))
(%i11) rectform(%);
(%o11) -9*%i*%pi/10

/*  principal value of square root function */

(%i12) zlist;
(%o12) [-1,%i,1,-%i]

(%i13) sqrt(zlist);
(%o13) [%i,(-1)^(1/4),1,sqrt(-%i)]
(%i14) rectform(%);
(%o14) [%i,%i/sqrt(2)+1/sqrt(2),1,1/sqrt(2)-%i/sqrt(2)]

(%i15) map ('psqrt,zlist);
(%o15) [%i,%i/sqrt(2)+1/sqrt(2),1,1/sqrt(2)-%i/sqrt(2)]

(%i16) z5;
(%o16) %e^-(9*%i*%pi/10)

(%i17) sqrt(z5);
(%o17) %e^-(9*%i*%pi/20)
(%i18) rectform(%);
(%o18) cos(9*%pi/20)-%i*sin(9*%pi/20)
(%i19) float(%);
(%o19) 0.156434-0.987688*%i

(%i20) psqrt (z5);
(%o20) %e^-(9*%i*%pi/20)
(%i21) rectform(%);
(%o21) cos(9*%pi/20)-%i*sin(9*%pi/20)
(%i22) float(%);
(%o22) 0.156434-0.987688*%i

/* consistency of use of rectform
   with a^b = exp(b*Log(a)) principal
   value definition */

(%i38) m1 : rectform ( (-1)^(1/8));
(%o38) %i*sin(%pi/8)+cos(%pi/8)
(%i39) m2 : exp(Log (-1)/8);
(%o39) %e^(%i*%pi/8)
(%i40) m3 : demoivre(m2);
(%o40) %i*sin(%pi/8)+cos(%pi/8)
(%i41) expand(m2^8);
(%o41) -1
--------------------------------------------------------------------
> 2. Is it the desired behavior of Maxima not to simplify
>   sqrt(1/z) -> 1/sqrt(z) for any z?
> A consequence is, that
>    sqrt(z)*sqrt(1/z) would not simplify to 1 for z>0.
> The current behavior of Maxima is to simplify sqrt(1/z) -> 1/sqrt(z), if
> Maxima can deduce z>0. Until Maxima 5.20 we had sqrt(1/z) -> 1/sqrt(z)
>  and sqrt(z)*sqrt(1/z) -> 1 for any z.
------------------------------------------------------

I would like Maxima to simplify sqrt(1/z) in the same
way that Macsyma does, when provided information
that either z > 0 or z < 0. Perhaps a global switch to
turn on that extra job.

--------------------------------------
> 3. Should we implement a principal square root function, which is the
> inverse of f(x):=x^2 for x>0 and is extended to the complex numbers in a
> way, which is consistent with the calculation of the principal value of
>  the square root function?
-----------------------------------
The present sqrt (in combination with rectform) is
already a (perhaps clunky) implementation of the
principle value definition of the square root function.
Perhaps a global complex_simp flag would include
an automatic use of rectform applied to what the
present form of sqrt returns.


fwiw,

Ted