# [Maxima] rectform rescue of principal value

Edwin Woollett woollett at charter.net
Wed Nov 3 13:59:35 CDT 2010

```On Nov. 2 I wrote:
----------------------------------------
------------------------------------------
I agree this p.v. business is only feasible for very
simple x and y, for example , z : (2+3*%i)^(1-%i)
will give consistent answers for Log(z)
and psqrt(z), and can be compared with
respectively, log(z) and sqrt(z).

An example where we get wildly different

z : (2+3*%i)^(asin(3+2*%i))

----------------------------------------
--------------------------------------------
NEW APPROACH:

By defining the principal value Log(z) in terms of
rectform acting at the top level of the definition
of z, we can automatically work with the
principle value of asin(zz) and get consistent
answers compared with the known ''true"
answer defined by working with the
numerical value of z.

Here is a record of the new definitions
the calc. of the 'true value' and the
symbolic calculation's reduction
to floats as a check of correctness.

--------------------------------------------
NEW DEF Log and  psqrt here  :

(%i1) (display2d:false,fpprintprec:8,ratprint:false,

Log (zz) := log (rectform (map ('rectform,zz))),

psqrt(zz) := (if zz = 0 then 0
else if integerp(zz) then sqrt(zz) else
rectform (exp (Log (zz)/2))  ),

toN(ee):= float (rectform (float (ee))) )\$

HERE IS OUR z

(%i2) z : (2+3*%i)^(asin(3+2*%i))\$

HERE IS NUMERICAL VALUE

(%i3) zn : toN (z);
(%o3) -0.161862*%i-0.470719

CHECK NUMERICAL LOG

(%i4) log(zn);
(%o4) -2.8103967*%i-0.697615

(%i5) Log(zn);
(%o5) -2.8103967*%i-0.697615

NOW FOR SYMBOLIC P.V. LOG

(%i6) Log(z);

(%o6) log(13^(atan((3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2))
/2)
*%e^(atan(3/2)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/2)
*cos(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan((3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)))
-%i*13^(atan((3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2))
/2)
*%e^(atan(3/2)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/2)
*sin(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan((3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2))))

NUMERICAL CHECK:

(%i7) float(%);
(%o7) -2.8103967*%i-0.697615

WHICH AGREES.

N0W DO SQRT "TRUE VALUE"

(%i8) sqrt(zn);
(%o8) 0.116301-0.695877*%i

(%i9) psqrt(zn);
(%o9) 0.116301-0.695877*%i

NOW FOR SYMBOLIC P.V.
SQUARE ROOT (COMPLICATED)

(%i10) psqrt(z);

(%o10) %i*%e^(log(13^atan(3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)/(sqrt(4*sqrt(10)-4)-2^(3/2)))
*%e^(atan(3/2)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2))
*sin(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)
/(sqrt(4*sqrt(10)-4)-2^(3/2))))
^2
+13^atan(3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)/(sqrt(4*sqrt(10)-4)-2^(3/2)))
*%e^(atan(3/2)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2))
*cos(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)
/(sqrt(4*sqrt(10)-4)-2^(3/2))))
^2)
/4)
*sin((-atan(sin(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
(3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)))
/cos(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
(3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2))))
-%pi)
/2)
+%e^(log(13^atan(3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)/(sqrt(4*sqrt(10)-4)-2^(3/2)))
*%e^(atan(3/2)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2))
*sin(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)
/(sqrt(4*sqrt(10)-4)-2^(3/2))))
^2
+13^atan(3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)/(sqrt(4*sqrt(10)-4)-2^(3/2)))
*%e^(atan(3/2)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2))
*cos(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
3/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)
-sqrt(4*sqrt(10)+4)
/(sqrt(4*sqrt(10)-4)-2^(3/2))))
^2)
/4)
*cos((-atan(sin(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
(3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2)))
/cos(log(13)*log((3-sqrt(4*sqrt(10)+4)/sqrt(2))^2
+(sqrt(4*sqrt(10)-4)/sqrt(2)-2)^2)
/4
-atan(3/2)*atan(
(3-sqrt(4*sqrt(10)+4)/sqrt(2))
/(sqrt(4*sqrt(10)-4)/sqrt(2)-2))))
-%pi)
/2)

FOR P.V. SQRT

(%i11) float(%);
(%o11) 0.116301-0.695877*%i
---------------------------------------------------------
which AGREES.

This approach can be extended to complex expressions in which we need
to apply rectform to more than just the top level of z.

Ted Woollett

```