Complex Numbers#
A complex number is a number that has both a real and imaginary component. They can be written in the form:
where \(a\) and \(b\) are real numbers and \(i=\sqrt{-1}\).
We often denote complex numbers by the letter \(z\), so \(z = a+bi\):
\(a\) is the real part of \(z\), which we denote \(\textrm{Re}(z) = a\).
\(b\) is the imaginary part of \(z\), which we denote \(\textrm{Im}(z) = b\).
\(z^* = a-bi\) is called the complex conjugate of \(z = a+bi\).
Just as we have a number line for real numbers, we can draw complex numbers on an x, y-axis called an Argand diagram with imaginary numbers of the y-axis and real numbers on the x-axis. We have drawn \(2+3i\) on the Argand diagram below.
Example
Find the imaginary and real parts of the following complex numbers, along with their complex conjugates:
\(z=-3+5i\)
\(z=1-2\sqrt{3}i\)
\(z=i\)
Solution:
For \(z=-3+5i\), we have \(\textrm{Re}(z) = -3\), \(\textrm{Im}(z) = 5\), and \(z^*=-3-5i\).
For \(z=1-2\sqrt{3}i\), we have \(\textrm{Re}(z) = 1\), \(\textrm{Im}(z) = -2\sqrt{3}\), and \(z^*=1+2\sqrt{3}\).
For \(z=i\), we have \(\textrm{Re}(z) = 0\), \(\textrm{Im}(z) = 1\), and \(z^*=-i\).
Different Form for Complex Numbers#
When a complex number \(z\) is in the form \(z=a+bi\), we say it is written in Cartesian form. We can also write complex numbers in:
Polar form: \(r(\cos{(\phi)} + i\sin{(\phi)})\)
Exponential form: \(r\exp{(i\phi)}\)
where the magnitude \(|z|\) (or modulus) of \(z\) is the lenght \(r\)
and the argument of \(z\) is the angle \(\phi\) (in radians)
This argument \(\phi\) is usually between \(-\pi\) and \(\pi\). Expressed mathematically, this is \(-\pi < \phi \leq \pi\).
We can see on the an Argand diagram, the relationship between the different forms for representing a complex number.
Example
Find the modulus and argument of the following complex numbers:
\(3+3i\)
\(-4+3i\)
\(-3i\)
4
Solution:
For \(3+3i\), we have \(|z|=\sqrt{3^2 + 3^2} = \sqrt{18}\) and \(\arg{(z)}=\tan^{-1}\left(\frac{3}{3}\right) = \frac{\pi}{4}\;\textrm{rad}\).
For \(-4+3i\), we have \(|z|=\sqrt{(-4)^2 + 3^2} = 5\) and \(\arg{(z)}=\tan^{-1}\left(\frac{3}{-4}\right) = -0.64\;\textrm{rad}\).
For \(-3i\), we have \(|z|=\sqrt{0^2 + (-3)^2} = 3\) and \(\arg{(z)}=\tan^{-1}\left(\frac{-3}{0}\right)\).
This calculation does not make sense, since we can’t divide by zero. However, if we imagine the Argand diagram, the argument is \(\arg{(z)}=\frac{\pi}{2}\;\textrm{rad}\), is the vector would be pointing negative along the \(\textrm{Im}(z)\) axis.
For \(4\), we have \(|z|=\sqrt{4^2 + 0^2} = 4\) and \(\arg{(z)}=\tan^{-1}\left(\frac{0}{4}\right) = 0\;\textrm{rad}\)
Python can natively handle complex numbers, but the numpy module is necessary to find the argument of a complex number, with the np.angle function.
z = complex(3, 3)
abs(z), np.angle(z)
(4.242640687119285, 0.7853981633974483)
The abs function is used to magnitude or modulus.
z = complex(-4, 3)
abs(z), np.angle(z)
(5.0, 2.498091544796509)
The numpy function is capable of handling the divide by zero appropriately.
z = complex(0, -3)
abs(z), np.angle(z)
(3.0, -1.5707963267948966)
z = complex(4, 0)
abs(z), np.angle(z)
(4.0, 0.0)
Example
Express \(4-5i\) in polar and exponential form.
Solution: First, we need to find the modulus and argument .
and
So, in polar form, we have
and in exponential form,
Radial Wave Function
Written in the exponential form, the radial wave function for a 2p orbital of hydrogen is:
Write this in polar form.
Solution: A complex number in exponential form: \(r\exp{(i\phi)}\) has the polar form \(r\left(\cos{(\phi)} + i\sin{(\phi)}\right)\).
Because of the \(\mp\) and \(\pm\) signs in this question, we have either:
Hence in the polar form, we have either:
Applications#
When using the quadratic formula:
we would not have known what to do if \(b^2-4ac\) was negative, however, now we are able to solve this square root using imaginary numbers.
Example
Solve the equation \(x^2+3x+12\), using the quadratic formula.
Solution: So we have that \(a=1\), \(b=3\), and \(c=12\), so the quadratic formula gives:
This gives us \(x = \frac{-3 + i\sqrt{39}}{2}\) and \(x = \frac{-3 - i\sqrt{39}}{2}\).
As we would expect, sympy can help us with this.
from sympy import symbols, solve
x = symbols('x')
solve(x**2 + 3*x + 12, x)
[-3/2 - sqrt(39)*I/2, -3/2 + sqrt(39)*I/2]
But we can also use the quadratic formula, however, it is necessary that our inputs for \(a\), \(b\), and \(c\) are complex-type variables.
def quadratic_formula(a, b, c):
"""
Returns the two solutions to the quadratic equation ax^2 + bx + c = 0.
:param a: Coefficient of x^2
:param b: Coefficient of x
:param c: Constant term
:return: A tuple containing the two roots
"""
discriminant = b**2 - 4 * a * c
root1 = (-b + np.sqrt(discriminant)) / (2 * a)
root2 = (-b - np.sqrt(discriminant)) / (2 * a)
return root1, root2
quadratic_formula(1+0j, 3+0j, 12+0j)
((-1.5+3.122498999199199j), (-1.5-3.122498999199199j))