# How to take conjugate of a function?

Naïvely this is what happens and it obviously is not helpful!

In[7]:= Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]]

Out[7]= -(1/2) E^(-I Conjugate[ϕ]) Sqrt[3/(2 π)] Conjugate[Sin[θ]]


So I tried stating initially that $\theta$ and $\phi$ are reals - but still that doesn't seem to have helped any bit,

 In[8]:= θ ∈ Reals; ϕ ∈ Reals;

In[9]:= SphericalHarmonicY[1, 1, θ, ϕ]

Out[9]= -(1/2) E^(I ϕ) Sqrt[3/(2 π)] Sin[θ]

In[10]:= Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]]

Out[10]= -(1/2) E^(-I Conjugate[ϕ]) Sqrt[3/(2 π)] Conjugate[Sin[θ]]


Kindly tell me how to do this? (...I want to calculate sums like $\sum\limits_{m=-\ell}^{\ell}\vert Y_{l,m} (\theta,\phi)\vert^2$...)

-
Try Simplify[Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]], θ ∈ Reals && ϕ ∈ Reals] –  Ｊ. Ｍ. Apr 22 '13 at 9:57
Simply writing θ ∈ Reals; ϕ ∈ Reals; is not the way to indicate to Mathematica that those variables are real. Try looking up $Assumptions and Assumptions. – Sjoerd C. de Vries Apr 22 '13 at 15:46 ## 3 Answers Almost always in such situations, ComplexExpand is your friend:  Conjugate[SphericalHarmonicY[1, 1, \[Theta], \[Phi]]] // ComplexExpand (* -(Sqrt[3/(2*Pi)]*Cos[\[Phi]]*Sin[\[Theta]])/2 + (I/2)*Sqrt[3/(2*Pi)]*Sin[\[Theta]]*Sin[\[Phi]] *)  - Thanks! But isn't there a way to just make Mathematica understand that theta and phi are reals? I mean, I want to do many calculations like this in one file and I would like to have it declared once and for all that \theta and \phi are reals. Isn't there a way for that? – user6818 Apr 21 '13 at 23:09 This thing of "ComplexExpand" doesn't seem to work if I say have a coefficient like of$(1/a)Y_{l,m}(\theta,\phi)$. Then ComplexExpand doesn't understand that$a$is real and is making an unnecessary mess of the expression. – user6818 Apr 22 '13 at 0:07 ComplexExpand does an expansion making the assumption that all variables and symbolic constants involved are real. There are not really "assertions" like \[theta] \[Element] Reals that do anything. Sometimes setting values for the global $Assumptions will do what you want, but that's only for affecting subsequent uses of certain functions such as Simplify and Integrate. –  murray Apr 22 '13 at 3:18

This is the spherical harmonic:

SphericalHarmonicY[1, 1, \[Theta], \[Phi]]


It returns this:

-(1/2) E^(I \[Phi]) Sqrt[3/(2 \[Pi])] Sin[\[Theta]]


And this is its complex conjugate:

SphericalHarmonicY[1, 1, \[Theta], \[Phi]] /. I -> -I


returning this:

-(1/2) E^(-I \[Phi]) Sqrt[3/(2 \[Pi])] Sin[\[Theta]]


as it can be expected.

-

Rule

{Complex[re_, im_] :> Complex[re, -im]}


seems to convert complex expressions which contain symbols which are meant to be real.

Rule

{I -> -I}


does not, even on simple example:

2 I /.{I -> -I}

2 I


the reason being that symbol I is automatically translated by Mathematica to

Complex[0, 1]


and rule above is interpreted by Mathematica as

Complex[0, 1] -> Complex[0, -1]


However, when I apply it to a simple expression (say, 2 + 3 I), I am working with a different expression (in this case Complex[2, 3]), so the rule is not applicable.

-
Your pattern is not exhaustive. For example ArcSin[2] is a complex number that won't get picked up by your pattern. –  Chip Hurst Dec 9 at 22:36