Hello,
At present the conjugate function in share/matrix/eigen.mac
has some problems, as described in SF bug reports # 1045514 and
1045531.
(https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1045514&group_id=4933,
https://sourceforge.net/tracker/?group_id=4933&atid=104933&func=detail&aid=1045531)
Thanks to Stavros for his work on these problems.
eigen.mac has conjugate(x) := sublis('([%i = - %i]), x)$.
There is also a conjugate function in share/simplification/functs.mac,
which has a similar definition. There isn't a conjugate function
in the main src directory.
Here is another definition, which doubtless has its own problems,
but I offer this in hopes that it is less broken than the current
definition, and that a discussion will lead to something better.
(%i1) conjugate(x):=
(if listp(x) then map (conjugate, x)
else if matrixp(x) then matrixmap (conjugate, x)
else ([rp: realpart(x), ip: imagpart(x)],
/* Attempt to detect cases in which realpart and imagpart
have punted. This test is too conservative. */
if freeof (nounify (realpart), rp)
and freeof (nounify (imagpart), ip)
then rp - %i*ip
else 'conjugate(x)))$ /* punt here if rp/ip did too */
(%i2) declare ([conjugate, nounify (conjugate)], [complex, additive,
outative])$
OK, that much is the definition. Now some examples.
(%i3) declare ([a, b, c, f, nounify(f)], complex)$
(%i4) declare ([x, y, z, g, nounify(g)], real)$
First set of examples. The elements of m are all complex.
The "Is imagpart(a) ... ?" emanates from computing realpart(a)
and imagpart(a) in conjugate. Shouldn't sqrt evaluate to a
noun form instead of calling asksign? Seems ugly but that's
discussion for another day.
(%i5) l: [x+%i*y, exp(%i*t), a, b+7*c, f(x), f(g(a)), sqrt(a)];
%i t
(%o5) [%i y + x, %e , a, 7 c + b, f(x), f(g(a)), sqrt(a)]
(%i6) m: transpose (matrix (l))$
(%i7) conjugate (m);
Is imagpart(a) positive, negative, or zero?
p;
[ x - %i y ]
[ ]
[ cos(t) - %i sin(t) ]
[ ]
[ conjugate(a) ]
[ ]
(%o7) [ 7 conjugate(c) + conjugate(b) ]
[ ]
[ conjugate(f(x)) ]
[ ]
[ conjugate(f(g(a))) ]
[ ]
[ conjugate(sqrt(a)) ]
Those all seem OK, although item 2 might be nicer as exp(-%i*t).
Second set of examples. These items are all real.
Evaluation of sqrt eventually leads to asksign again.
(%i8) l: [x, 'carg (x+y*%i), 'cabs (x+y*%i), g(a), g(f(a)), sqrt(y)];
(%o8) [x, carg(%i y + x), cabs(%i y + x), g(a), g(f(a)), sqrt(y)]
(%i9) m: transpose (matrix (l))$
(%i10) conjugate (m);
Is y positive, negative, or zero?
p;
[ x ]
[ ]
[ carg(%i y + x) ]
[ ]
[ conjugate(cabs(%i y + x)) ]
(%o10) [ ]
[ g(a) ]
[ ]
[ g(f(a)) ]
[ ]
[ sqrt(y) ]
These are all correct enough but realpart and imagpart don't
know that cabs is real, hence conjugate(cabs(%i y + x)).
Otoh realpart and imagpart do know carg is real.
I tried to use tellsimp to tell some identities to the simplifier
-- realpart(conjugate(a)) = realpart(a), imagpart(conjugate(a)) =
-imagpart(a), conjugate(conjugate(a)) = a -- but these the
simplifier didn't seem to recognize these expressions so I gave up.
With the above definition, realpart(conjugate(a)),
imagpart(conjugate(a)), and conjugate(conjugate(a)) yield noun forms.
Not incorrect, but not very helpful.
Anyway perhaps someone will have some ideas here.
Robert Dodier
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250