## #411 rectform/carg doesn't normalize exp(%i*n) (also asin, log)

closed
nobody
5
2009-02-24
2003-10-01
No

carg(exp(%i*x)) =&gt; x (OK?)
carg(exp(%i*10.0)) =&gt; 10.0 (No?)

carg(exp(%i*-%pi)) =&gt; %pi (OK)
float(carg(exp(%i*-%pi))) =&gt; 3.14 (OK)
carg(exp(%i*float(-%pi))) =&gt; -3.14 (?)

float(carg(asin(-%i*10))) =&gt; -1.57 (OK)
carg(asin(-%i*10)),numer =&gt; 4.71 (No!)

float(rectform(log(-%i*10))) =&gt; 2.30 - 1.57*%I (OK)
rectform(log(-%i*10)),numer =&gt; 2.30+4.71*%I (No!)

Presumably the principal values is what is wanted. I will
correct that.

This is related to the fact that carg(exp(%i*x)) doesn't
normalize x to (-pi,pi] when x is not an explicit multiple
of pi:

carg(exp(%i*10)) =&gt; 10
carg(exp(%i*x)) =&gt; x
but
carg(exp(%i*(3*%pi-x))) =&gt; %pi-x

How far should this go? I think it's pretty clear for the
float/bfloat case, but how about carg(exp(%i*10))?
Should that really return 10-4*%pi? Currently, it goes
the other way around!: exp(%i*(10-4*%pi)) actually
simplifies to exp(%i*10)....

## Discussion

• Robert Dodier - 2005-07-16

Logged In: YES
user_id=501686

Well, how about carg (exp (%i*10)) => 'mod (10, 2*%pi) ??

• Robert Dodier - 2005-07-16
• labels: --> 460522

• Barton Willis - 2005-07-18

Logged In: YES
user_id=895922

How about 'nummod'? See my recent Maxima
list posting and "Concrete Mathematics" by
Graham, Knuth, and Patashnik, Section 3.4

(%i2) f(x) := %pi - nummod(%pi-x,2*%pi)\$
(%i3) f(-%pi);
(%o3) %pi
(%i4) f(0);
(%o4) 0
(%i5) f(%pi);
(%o5) %pi
(%i6) f(%pi + 1/10^9);
(%o6) 1/1000000000-%pi
(%i7) f(%pi - 1/10^9);
(%o7) %pi-1/1000000000
(%i8)

Barton

• Robert Dodier - 2006-09-09
• labels: 460522 --> Lisp Core - Complex

• Dan Gildea - 2009-02-24
• status: open --> closed

• Dan Gildea - 2009-02-24

In current cvs:

(%i6) carg(exp(%i*x));
(%o6) x

(%i7) carg(exp(%i*10.0));
(%o7) -2.566370614359173

(%i8) carg(exp(%i*-%pi));
(%o8) %pi

(%i9) float(carg(exp(%i*-%pi)));
(%o9) 3.141592653589793

(%i10) carg(exp(%i*float(-%pi)));
(%o10) -3.141592653589793

(%i11) float(carg(asin(-%i*10)));
(%o11) -1.570796326794897

(%i12) float(carg(asin(-%i*10)));
(%o12) -1.570796326794897

(%i13) float(rectform(log(-%i*10)));
(%o13) 2.302585092994046-1.570796326794897*%i

(%i14) rectform(log(-%i*10)),numer;
(%o14) log(10)-%i*%pi/2

not sure why that last one didn't come out numerically:

(%i18) log(-%i*10),numer;
(%o18) 2.302585092994046-1.570796326794897*%i