# How to take conjugate of a function?

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

In:= Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]]
Out= -(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:= θ ∈ Reals; ϕ ∈ Reals;

In:= SphericalHarmonicY[1, 1, θ, ϕ]
Out= -(1/2) E^(I ϕ) Sqrt[3/(2 π)] Sin[θ]

In:= Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]]
Out= -(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}\left| Y_{l,m} (\theta,\phi)\right|^2$.)

• Try Simplify[Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]], θ ∈ Reals && ϕ ∈ Reals] Apr 22, 2013 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. Apr 22, 2013 at 15:46 ## 4 Answers Almost always in such situations, ComplexExpand is your friend: Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]] // ComplexExpand (* -(Sqrt[3/(2*Pi)]*Cos[ϕ]*Sin[θ])/2 + (I/2)*Sqrt[3/(2*Pi)]*Sin[θ]*Sin[ϕ] *)  • 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? Apr 21, 2013 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. Apr 22, 2013 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. Apr 22, 2013 at 3:18
• I disagree with this answer, though not to the extent of downvoting. ComplexExpand does more, than just assuming all symbols to be real. As you can see, It has transformed Exp[I \[Phi]] to Cos[\[Phi]] + I Sin[\[Phi]]. I view this as undesirable behavior and would often prefer to see it drop Conjugates, with minimal alteration of the form of the expression. Apr 15, 2015 at 13:24
• I agree with LLIAMnYP. Here is a minimal method that avoid this issue: Refine[Conjugate[SphericalHarmonicY[1, 1, θ, ϕ]], _Symbol ∈ Reals]. For an exhaustive discussion, see here. Sep 27, 2017 at 18:53

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 is a complex number that won't get picked up by your pattern. Dec 9, 2014 at 22:36

1. Define a symbol for the complex conjugate, e.g. Ybar
Y[l_, m_, θ_, ϕ_] := SphericalHarmonicY[l, m, θ, ϕ]

3. Define Ybar
Ybar[l_, m_, θ_, ϕ_] := SphericalHarmonicY[l, m, θ, ϕ] /. I -> -I