How to find the real part of the following function in Mathematica? The function is $$e^{-i\psi}\langle\beta|\alpha\rangle$$. When expanded, it is given as: $$e^{-i\psi}\exp\left[\beta^{*}\alpha-\vert\alpha\vert^{2}/2-\vert\beta\vert^{2}/2\right]$$

The following is what I have written in Mathematica.

E^(-I ψ - 
 1/2 α Conjugate[α] + α Conjugate[β] - 
 1/2 β Conjugate[β])

2 Answers 2


Applying the advice of @Bob Hanlon, one gets the answer

expr = Exp[-I \[Psi] - 
   1/2 \[Alpha] Conjugate[\[Alpha]] + \[Alpha] Conjugate[\[Beta]] - 
   1/2 \[Beta] Conjugate[\[Beta]]]

Re[expr] // ComplexExpand[#, {\[Alpha], \[Beta]}] &

(*  E^(-(1/2) Im[\[Alpha]]^2 + Im[\[Alpha]] Im[\[Beta]] - Im[\[Beta]]^2/
  2 - Re[\[Alpha]]^2/2 + Re[\[Alpha]] Re[\[Beta]] - Re[\[Beta]]^2/2)
  Cos[\[Psi] + Im[\[Beta]] Re[\[Alpha]] - Im[\[Alpha]] Re[\[Beta]]]  *)

which is correct, but lengthily. If you need to keep it more concise you can do the following:

Step 1:

 expr2 = expr /. E^(-I \[Psi] + x_) -> E^(-I \[Psi])*Hold[E^x]

(*  E^(-I \[Psi])
     2) \[Alpha] Conjugate[\[Alpha]] + \[Alpha] Conjugate[\[Beta]] - 
   1/2 \[Beta] Conjugate[\[Beta]])]  *)

Step 2:

ExpToTrig[expr2] /. Complex[0, y_] -> 0 // ReleaseHold

(*  E^(-(1/2) \[Alpha] Conjugate[\[Alpha]] + \[Alpha] Conjugate[\[Beta]] \
- 1/2 \[Beta] Conjugate[\[Beta]]) Cos[\[Psi]]  *)

To better visualize the result below I show it as the image:

enter image description here

Have fun!


I think I got the answer.

Re[E^(-I ψ - 
 1/2 α Conjugate[α] + α Conjugate[β] - 
 1/2 β Conjugate[β])] // ComplexExpand
  • 3
    $\begingroup$ When you use ComplexExpand it assumes that all of variables (i.e., {α, β, ψ}) are real. If that is not the case, you need to tell ComplexExpand which variables are complex. For example, if only ψ is real and {α, β} are complex, use Re[expr] // ComplexExpand[#, {α, β}] & $\endgroup$
    – Bob Hanlon
    Apr 1, 2021 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.