# 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.


```python
from sympy import *
init_printing()
```


```python
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``.


```python
I**2
```


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

### Real and imaginary parts


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


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

### Addition


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

Addition is commutative


```python
display(z1 + z2)
display(z2 + z1)
```

Addition is also associative


```python
display(z1 + (z2 + z3))
display((z1 + z2) + z3)
```

### Multiplication


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

Multiplication is commutative


```python
display(z1 * z2)
display(z2 * z1)
```

Multiplication is associative


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

Multiplication is distributive over addition


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

### Complex conjugate


```python
display(z1)
display(conjugate(z1))
```

### Difference


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

### Division


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

## 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)\, .$$


```python
Abs(z1)
```


```python

```


```python
from IPython.core.display import HTML
def css_styling():
    styles = open('./styles/custom_barba.css', 'r').read()
    return HTML(styles)
css_styling()
```





<link href='http://fonts.googleapis.com/css?family=Fenix' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>
<style>
/* 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 )
}
</style>








```python

```

6dca2882389e59d88d0dedc7e6bd31f55b6bb8d4
ipynb
Jupyter Notebook
notebooks/complex numbers.ipynb
nicoguaro/AdvancedMath
2749068de442f67b89d3f57827367193ce61a09c
MIT
2017-06-29T17:45:20.000Z
2022-02-06T20:14:29.000Z
notebooks/complex numbers.ipynb
nicoguaro/AdvancedMath
2749068de442f67b89d3f57827367193ce61a09c
MIT
notebooks/complex numbers.ipynb
nicoguaro/AdvancedMath
2749068de442f67b89d3f57827367193ce61a09c
MIT
2019-04-22T08:08:56.000Z
2022-01-27T08:15:53.000Z
Qwen/Qwen-72B
1. YES
2. YES