Question: evalc and simplify

1. There is this weird bug:

evalc(Re((Re(z)+I*Im(z))^2)) assuming z::complex;
                                2
                               z 

which looks like the assumption got lost somewhere along the way.

2. simplify and evalc can't automatically handle these:

simplify(z-Re(z)-I*Im(z));
                      z - Re(z) - I Im(z)

evalc(z-Re(z)-I*Im(z)) assuming z::complex;
                      z - Re(z) - I Im(z)

simplify(Re(z)^2+Im(z)^2-abs(z)^2);
                          2        2      2
                     Re(z)  + Im(z)  - |z| 

evalc(Re(z)^2+Im(z)^2-abs(z)^2) assuming z::complex;
                          2        2      2
                     Re(z)  + Im(z)  - |z| 

One way to make it work is to do subs(z=Re(z)+I*Im(z),...) and then pass it to evalc. But see point 1. Another way that sometimes work is convert(...,abs).

Side note on convert: convert(...,Re) allows Im as well as Re. I think that's not very useful: typically the point of convert is that I want to get rid of other functions.

3. evalc tends to leave functions of complex argument unexpanded:

evalc(conjugate(sin(z))) assuming z::complex;
                                /_\
                             sin\z/

The real and imaginary parts aren't separated. Again, one way to make it work is this:

evalc(conjugate(sin(Re(z)+I*Im(z)))) assuming z::complex;
       sin(Re(z)) cosh(Im(z)) - I cos(Re(z)) sinh(Im(z))

But see point 1. Also, using just Re(z) and Im(z) won't always give the simplest form.

In fact, even for Re(sin(z)), which is technically already the real part, I'd say it's not very useful for evalc to just give back Re(sin(z)). sin(Re(z))*cosh(Im(z)) is a more useful output, with functions applied only to real quantities.

Using x+I*y instead of z won't help with the simplify examples, but evalc seems to work fine when all variables are assumed to be real.

 

Please Wait...