> This test should ensure that the simplifier returns the orginal function
> without any simplification. But I have also to solve the problem that the
> evaluated function is something like ((%function simp) arg) and the quoted
> function looks like (($function) arg). Is there a more simple way to do such a
> test?
I have formulated the test function the following way:
equal_function(exp1,exp2):=block(
if (?listp(exp1)
and (?listp(exp2))
and is(equal(?stripdollar(op(exp1)),?stripdollar(op(exp2))))
and is(equal(args(exp1), args(exp2)))) then return(true),
false
);
Now I can test something like is arg(-z) equal '(arg(-z)).
I am building up a test table with expected results for the Complex compents.
Results in brackets [] are wrong or not simplified as expected. To get these
results I have introduced a Complex sgn function and have started to modify the
functions cabs und carg (here called arg). Most problems we get with the carg
function.
(%i1) load("rtest_complex.mac");
z |z| arg(z) re(z) im(z) conj(z) sgn(z)
0 0 [0] 0 0 0 0
1 1 0 1 0 1 1
-1 1 %pi -1 0 -1 -1
%i 1 %pi/2 0 1 -%i %i
-%i 1 [%pi/2] 0 -1 %i -%i
%i+1 sqrt(2) %pi/4 1 1 1-%i (%i+1)/sqrt(2)
%i-1 sqrt(2) 3*%pi/4 -1 1 -%i-1 (%i-1)/sqrt(2)
-%i-1 sqrt(2) -3*%pi/4 -1 -1 %i-1 (-%i-1)/sqrt(2)
2 2 0 2 0 2 1
-2 2 %pi -2 0 -2 -1
-2*%i 2 -%pi/2 0 -2 2*%i -%i
%i+2 sqrt(5) atan(1/2) 2 1 2-%i (%i+2)/sqrt(5)
%pi %pi 0 %pi 0 %pi 1
%e %e 0 %e 0 %e 1
z cabs(z) arg(z) re(z) im(z) conj(z) [z/cabs(z)]
-z cabs(z) [arg(z)] -re(z) -im(z) -conj(z) [-z/cabs(z)]
x abs(x) arg(x) x 0 x [x/abs(x)]
x1 x1 0 x1 0 x1 1
x2 -x2 %pi x2 0 x2 -1
y abs(y) arg(y) y 0 y [y/abs(y)]
y1 y1 0 y1 0 y1 1
y2 -y2 %pi y2 0 y2 -1
%i*y abs(y) [arg(y)+%pi/2] 0 y -%i*y %i*y/abs(y)
%i*y1 y1 %pi/2 0 y1 -%i*y1 %i
%i*y2 -y2 -%pi/2 0 y2 -%i*y2 -%i
(%o1) rtest_complex.mac
(%i2) facts();
(%o2) [kind(z, complex), kind(z1, complex), kind(z2, complex), kind(x, real),
kind(x1, real), kind(x2, real), kind(y, real), kind(y1, real), kind(y2, real),
x1 > 0, 0 > x2, y1 > 0, 0 > y2]
Dieter Kaiser