Message Boards Message Boards

0
|
4807 Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

ComplexExpand, Conjugate, Piecewise - an unexpected result

Posted 10 years ago
ComplexExpand[Conjugate[Piecewise[{{-I,a>0}},I]]]

The above expresstion yields (a is an undetermined symbol, you can replace it with 1 if you like)
Piecewise[{{-I,a>0}},I]

I expect this expression to yield
Piecewise[{{I,a>0}},-I]

because this is what conjugate do. It seems that Conjugate function have been ignored.
POSTED BY: chong wang
4 Replies
The following code produce the same thing. 
In[3]:= Conjugate[f[x]]
Out[3]= Conjugate[f[x]]
In[4]:= ComplexExpand[%]
Out[4]= f[x]

The documentation says it does not always propagate into the expression. Once it stays outside, the ComplexExpand simply kills the head. 

POSTED BY: Shenghui Yang
Posted 10 years ago
I still don't understand.

The document just say it does not always propagate into arguments, but how can ComplexExpand kill it? This gives wrong results!

During a very complex calculation, I just cannot make sure every Conjugate is well dealt with (they are just intermediate results that I cannot see), and it accually took me hours to find this problem in a very big calculation. 
POSTED BY: chong wang
I agree. It should stay like the input if it is not sure. 
ComplexExpand[Conjugate[Piecewise[{{-I, a > 0}}, I]]]

If you give "a" a value the result is correct 
In[31]:= ComplexExpand[Conjugate[Piecewise[{{-I,1>0}},I]]]
Out[31]= I

or use set delay
In[32]:= f[a_]:=ComplexExpand[Conjugate[Piecewise[{{-I,a>0}},I]]]
In[33]:= f[1]
Out[33]= I

You can make a suggestion to support@wolfram.com about this concern. 
POSTED BY: Shenghui Yang
Conjugate is primarily for numbers and expressions that represent numbers (such as Root objects).

If you want Conjugate to work on the parameters inside an expression,
use Map with a level specification.  For example,
In[1]:= Map[ Conjugate, Piecewise[{{-I, a > 0}}, I], {-1} ]
Out[1]= Piecewise[{{I, Conjugate[a] > 0}}, -I]

In[2]:= FullSimplify[ %,  Element[a, Reals] ]
Out[2]= Piecewise[{{-I, a <= 0}}, I]
POSTED BY: Bruce Miller
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract