# Complex numbers and operation on complex numbers

From A.G. Sveshnokov, A.N. Tikhonov (1982). The theory of functions of a complex variable. Section 1.1.

## The concept of a complex number

A complex number $z$ is characterized by a pair of real numbers $(a, b)$. The first number $a$ of the pair $(a, b)$ is called the real part of the complex number $z$ and is denoted by $a =\mathrm{Re}\, z$; the second number $b$ of the pair $(a, b)$ is called the imaginary part of the complex number $z$ and is symbolized by $b=\mathrm{Im}\, z$.

Two complex numbers $z_1 = (a_1, b_1)$ and $z_2 = (a_2, b_2)$ are equal only when both the real and imaginary parts are equal, that is, $z_1 = z_2$ only when $a_1 = a_2$ and $b_1 = b_2$.

## Operations on complex numbers

Let us now define algebraic operations involving complex numbers.

The sum of two complex numbers $z_1 = (a_1, b_1)$ and $z_2 = (a_2, b_2)$ is a complex number $z = (a, b)$, where $a = a_1 + a_2$, $b = b_1 + b_2$. The commutative and associative laws for addition, $z_1 + z_2 = z_2 + z_1$ and $z_1 + (z_2 + z_3) = (z_1 + z_2) + z_3$, hold true. As in the domain of real numbers, zero is a complex number $0$ such that the sum of it and any complex number $z$ is equal to $z$, that is, $z + 0 = z$. There is a unique complex number $0 = (0, 0)$ that possesses this property.

The product of the complex numbers $z_1 = (a_1, b_1)$ and $z_2 = (a_2, b_2)$ is a complex number $z = (a, b)$ such that $a = a_1 a_2 - b_1 b_2$, $b = a_1 b_2 + a_2 b_1$. In this definition of a product, we find that the commutative $[z_1 z_2 = z_2 z_1]$, associative $[z_1 (z_2\cdot z_3) = (z_1\cdot z_2) z_3]$ and distributive $[(z_1 + z_2) z_3 = z_1 z_3 + z_2 z_3]$ laws hold.

Let us include the real numbers in the set of complex numbers and regard the real number $a$ as the complex number $a = (a, 0)$. Then, as follows from the definition of the operations of addition and miltiplication, the familiar rules involving real numbers hold true for complex numbers as well. Thus, the set of complex numbers is regarded as an extension of the set of real numbers. Note that multiplication by a real unit $(1, 0)$ does not change a complex number: $z\cdot 1 = z$.

A complex number of the form of the form $z = (0, b)$ is called a pure imaginary number (or just imaginary number) and is symbolized as $z = ib$. The pure imaginary number $(0, b) = ib$ may be regarded as the product of the imaginary unit $(0, 1)$ and real number $(b, 0)$. The imaginary unit is commonly denoted by the symbol $(0, 1) = i$. By virtue of the definition of a product of complex numbers, the following relation holds true: $i\cdot i = i^2 = -1$. It enables one to attribute a direct algebraig meaning to the real-imaginary form of a complex number:

$$z = (a, b) = a + ib\, ,$$

and perform operations of addition and multiplication of complex numbers in accordance with the usual rules of the algebra of polynomials.

The complex number $\bar{z} = a - ib$ is said to be the complex conjugate of $z = a + ib$.

The operation of substraction of complex numbers is defined as the inverse operation of addition. A complex number $z = a + ib$ is termed the difference between the complex numbers $z_1 = a_1 + ib_1$ and $z_2 = a_2 + ib_2$ if $a = a_1 - a_2$, $b = b_1 - b_2$.

The operation of dividing complex numbers is defined as the inverse operation of multiplication. A complex number $z = a + ib$ is called the quotient of the complex numbers $z_1 = a_1 + ib_1$ and $z_2 = a_2 + ib_2 \neq = 0$ if $z_1 = z\cdot z_2$, whence it follows that the real part $a$ and the imaginary part $b$ of the quotient $z$ are found from the linear system of algebraic equations

\begin{align} &a_2 a - b_2 b = a_1\\ &b_2 a + a_2 b = b_1 \end{align}

with the determinant $a_2^2 + b_2^2$ different from zero. Solving this system, we get

$$z = \frac{z_1}{z_2} = \frac{a_1 a_2 + b_1 b_2}{a_2^2 + b_2^2} + i \frac{b_1 a_2 - a_1 b_2}{a_2^2 + b_2^2}\, .$$

## Operations on complex numbers using SymPy

Let us repeat the operations described above using SymPy.



In [1]:

from sympy import *
init_printing()




In [2]:

a, a1, a2, a3 = symbols("a a1 a2 a3", real=True)
b, b1, b2, b3 = symbols("b b1 b2 b3", real=True)



In SymPy the imaginary unit is represented by I.



In [3]:

I**2




Out[3]:

$\displaystyle -1$




In [4]:

z1 = a1 + b1*I
z2 = a2 + b2*I
z3 = a3 + b3*I
display(z1)
display(z2)
display(z3)




$\displaystyle a_{1} + i b_{1}$

$\displaystyle a_{2} + i b_{2}$

$\displaystyle a_{3} + i b_{3}$



### Real and imaginary parts



In [5]:

# Real part
display(re(z1))
display(re(z2))




$\displaystyle a_{1}$

$\displaystyle a_{2}$




In [6]:

# Imaginary part
display(im(z1))
display(im(z2))




$\displaystyle b_{1}$

$\displaystyle b_{2}$





In [7]:

display(z1 + z2)
display(re(z1 + z2))
display(im(z1 + z2))




$\displaystyle a_{1} + a_{2} + i b_{1} + i b_{2}$

$\displaystyle a_{1} + a_{2}$

$\displaystyle b_{1} + b_{2}$





In [8]:

display(z1 + z2)
display(z2 + z1)




$\displaystyle a_{1} + a_{2} + i b_{1} + i b_{2}$

$\displaystyle a_{1} + a_{2} + i b_{1} + i b_{2}$





In [9]:

display(z1 + (z2 + z3))
display((z1 + z2) + z3)




$\displaystyle a_{1} + a_{2} + a_{3} + i b_{1} + i b_{2} + i b_{3}$

$\displaystyle a_{1} + a_{2} + a_{3} + i b_{1} + i b_{2} + i b_{3}$



### Multiplication



In [10]:

display(z1 * z2)
display(re(z1 * z2))
display(im(z1 * z2))




$\displaystyle \left(a_{1} + i b_{1}\right) \left(a_{2} + i b_{2}\right)$

$\displaystyle a_{1} a_{2} - b_{1} b_{2}$

$\displaystyle a_{1} b_{2} + a_{2} b_{1}$



Multiplication is commutative



In [11]:

display(z1 * z2)
display(z2 * z1)




$\displaystyle \left(a_{1} + i b_{1}\right) \left(a_{2} + i b_{2}\right)$

$\displaystyle \left(a_{1} + i b_{1}\right) \left(a_{2} + i b_{2}\right)$



Multiplication is associative



In [12]:

display(expand(z1 * (z2 * z3)))
display(expand((z1 * z2) * z3))




$\displaystyle a_{1} a_{2} a_{3} + i a_{1} a_{2} b_{3} + i a_{1} a_{3} b_{2} - a_{1} b_{2} b_{3} + i a_{2} a_{3} b_{1} - a_{2} b_{1} b_{3} - a_{3} b_{1} b_{2} - i b_{1} b_{2} b_{3}$

$\displaystyle a_{1} a_{2} a_{3} + i a_{1} a_{2} b_{3} + i a_{1} a_{3} b_{2} - a_{1} b_{2} b_{3} + i a_{2} a_{3} b_{1} - a_{2} b_{1} b_{3} - a_{3} b_{1} b_{2} - i b_{1} b_{2} b_{3}$





In [13]:

display(expand((z1 + z2) * z3))
display(expand(z1 * z3 + z2 * z3))




$\displaystyle a_{1} a_{3} + i a_{1} b_{3} + a_{2} a_{3} + i a_{2} b_{3} + i a_{3} b_{1} + i a_{3} b_{2} - b_{1} b_{3} - b_{2} b_{3}$

$\displaystyle a_{1} a_{3} + i a_{1} b_{3} + a_{2} a_{3} + i a_{2} b_{3} + i a_{3} b_{1} + i a_{3} b_{2} - b_{1} b_{3} - b_{2} b_{3}$



### Complex conjugate



In [14]:

display(z1)
display(conjugate(z1))




$\displaystyle a_{1} + i b_{1}$

$\displaystyle a_{1} - i b_{1}$



### Difference



In [15]:

display(z1 - z2)
display(re(z1 - z2))
display(im(z1 - z2))




$\displaystyle a_{1} - a_{2} + i b_{1} - i b_{2}$

$\displaystyle a_{1} - a_{2}$

$\displaystyle b_{1} - b_{2}$



### Division



In [16]:

display(z1 / z2)
display(factor(re(z1 / z2)))
display(factor(im(z1 / z2)))




$\displaystyle \frac{a_{1} + i b_{1}}{a_{2} + i b_{2}}$

$\displaystyle \frac{a_{1} a_{2} + b_{1} b_{2}}{a_{2}^{2} + b_{2}^{2}}$

$\displaystyle - \frac{a_{1} b_{2} - a_{2} b_{1}}{a_{2}^{2} + b_{2}^{2}}$



## The geometric interpretation of complex numbers

The study of complex numbers is greatly facilitated by interpretating them geometrically. Insofar as a complex number is defined as a pair of real numbers, it is natural to depict the complex number $z = a + ib$ as a point in the $x$, $y$-plane with Cartesian coordinates $x = a$ and $y = b$. The number $z=0$ corresponds to the origin of the plane. We shall henceforward call this the complex plane; the axis of the abscissas is the real axis, the axis of the ordinates is the imaginary axis of the complex plane. We have thus established a reciprocal one-to-one correspondence between the set of all complex numbers and the set of points the complex plane, and also between the set of al complex numbers $z = a + ib$ and the set of free vectors, the projections $x$ and $y$ of which on the axis of abscissas and the axis of ordinates are, respectively, equal to $a$ and $b$.

There is another extremely important form of representing complex numbers. It is possible to define the position of a point in the plane by means of polar coordinates $(\rho, \varphi)$, where $\rho$ is the distance of the point from the origin, and $\varphi$ is the angle between the radius vector with the positive direction of the axis of abscissas. The positive direction of the variation of the angle $\varphi$ is counterclockwise $(-\infty < \varphi < \infty)$. Taking advantage of the relationship between Cartesian and polar coordinates

\begin{align} &x = \rho \cos\varphi\\ &y = \rho \sin\varphi\, , \end{align}

we get the so-called trigonometric form (or polar form) of a complex number:

$$z = \rho(\cos\varphi + i\sin\varphi)\, .$$


In [17]:

Abs(z1)




Out[17]:

$\displaystyle \sqrt{a_{1}^{2} + b_{1}^{2}}$




In [ ]:




In [18]:

from IPython.core.display import HTML
def css_styling():
return HTML(styles)
css_styling()




Out[18]:

/* Based on Lorena Barba template available at: https://github.com/barbagroup/AeroPython/blob/master/styles/custom.css*/
@font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}
div.cell{
width:800px;
margin-left:16% !important;
margin-right:auto;
}
h1 {
font-family: 'Alegreya Sans', sans-serif;
}
h2 {
font-family: 'Fenix', serif;
}
h3{
font-family: 'Fenix', serif;
margin-top:12px;
margin-bottom: 3px;
}
h4{
font-family: 'Fenix', serif;
}
h5 {
font-family: 'Alegreya Sans', sans-serif;
}
div.text_cell_render{
font-family: 'Alegreya Sans',Computer Modern, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
line-height: 135%;
font-size: 120%;
width:600px;
margin-left:auto;
margin-right:auto;
}
.CodeMirror{
font-family: "Source Code Pro";
font-size: 90%;
}
/* .prompt{
display: None;
}*/
.text_cell_render h1 {
font-weight: 200;
font-size: 50pt;
line-height: 100%;
color:#CD2305;
margin-bottom: 0.5em;
margin-top: 0.5em;
display: block;
}
.text_cell_render h5 {
font-weight: 300;
font-size: 16pt;
color: #CD2305;
font-style: italic;
margin-bottom: .5em;
margin-top: 0.5em;
display: block;
}
.warning{
color: rgb( 240, 20, 20 )
}

MathJax.Hub.Config({
TeX: {
extensions: ["AMSmath.js"]
},
tex2jax: {
inlineMath: [ ['$','$'], ["\$","\$"] ],
displayMath: [ ['$$','$$'], ["\$","\$"] ]
},
displayAlign: 'center', // Change this to 'center' to center equations.
"HTML-CSS": {
styles: {'.MathJax_Display': {"margin": 4}}
}
});




In [ ]: