More work on the functions for the complex components
Subject: More work on the functions for the complex components
From: Dieter Kaiser
Date: Tue, 5 May 2009 20:30:09 +0200
I would like to suggest two further improvements of the functions for the
complex components:
1. Simplification of realpart/imagpart with conjugate as expression
As mentioned in the bug report ID: 1045531 "real/imagpart don't know about
conjugate" the following extension to risplit will give more correct
simplifications for expressions with the function conjugate. The results will
be:
(%i3) declare(z,complex)$
(%i4) realpart(conjugate(z));
(%o4) realpart(z)
(%i5) imagpart(conjugate(z));
(%o5) -imagpart(z)
(%i6) realpart(conjugate(sin(z)));
(%o6) cosh(imagpart(z))*sin(realpart(z))
(%i7) imagpart(conjugate(sin(z)));
(%o7) -sinh(imagpart(z))*cos(realpart(z))
This is the code:
+ ((eq (caar l) '$conjugate)
+ (cons (simplify (list '(%realpart) (cadr l)))
+ (mul -1 (simplify (list '(%imagpart) (cadr l))))))
2. Change standard behavior of rectform
Maxima assumes that all unknown functions are real valued. See the bug report
ID: 1238141 "realpart(f(x+%i*y))".
We can change this in the function risplit in rpart.lisp. Now we get:
(%i22) rectform(f(x));
(%o22) realpart(f(x))+%i*imagpart(f(x))
(%i23) realpart(f(x));
(%o23) realpart(f(x))
(%i24) imagpart(f(x));
(%o24) imagpart(f(x))
This extension does not change the result for known functions:
(%i25) rectform(sin(x));
(%o25) sin(x)
(%i26) rectform(sin(z));
(%o26) cosh(?%imagpart(z))*sin(?%realpart(z))
+%i*sinh(?%imagpart(z))*cos(?%realpart(z))
This is the changed code:
@@ -356,7 +360,10 @@
(risplit-noun l))
((and (eq (caar l) '%product) (not (free (cadr l) '$%i)))
(risplit-noun l))
- (t (cons l 0)))))
+ (t
+; (cons l 0))))) <-- This is the old standard behavior
+ (cons (list '(%realpart) l)
+ (list '(%imagpart) l))))))
The testsuite has no problems with both extensions of the code.
Is there any problem I do not see? Should I commit the changes.
Hint:
We can add further code to look for real valued functions and add a property
like maps-reals-to-reals. With such extensions we can improve the handling of
functions further.
Dieter Kaiser