Mathematica uses the capital letter I to represent the square root of -1. Type
Sqrt[-1]and you'll get the answer
IYou can use I in expressions: the complex number 2 + 3i is represented as
2 + 3 Iin Mathematica. The generic complex number (x + y i) is written as
x + y Ior, equivalently,
x + I yMathematica has a tendency to "alphabetize" things, so it will usually print out (x + y i) in the second form.
Mathematica uses the function Conjugate to take the complex conjugate of a number. Try it:
a = 2 + 3 I Conjugate[a] 2 - 3 IWe know that the complex conjugate of (x + y i) is (x - y i). But Mathematica gives us
Conjugate[x + y I] Conjugate[x + I y]which, needless to say, is not very informative.
The problem is that we have not specified whether x and y are real or complex numbers, and Mathematica won't make any assumptions about x and y without our help. If x and y are themselves complex numbers, then the conjugate of (x + y i) is not simply (x - i y). To tell Mathematica that x and y are real numbers, use the ComplexExpand command:
ComplexExpand[ Conjugate[x + y I] ] x - I yNow we get the expected result. Remember to use ComplexExpand when working with complex functions like wavefunctions.
Other parts of the Mathematica tutorial: