Euler’s secret sauce: Complex numbers, Phasors and their role in AC Electrical Systems

We hope you find this tutorial useful, please share it if you do!

This tutorial covers how complex numbers, and especially the complex exponential form are used in Electrical Engineering. It describes the various forms of complex numbers available: cartesian, polar and exponential (Euler form), shows the derivations to switch between them: cartesian $\rightarrow$ polar and polar $\rightarrow$ complex exponential form.

Authors

1. Background to Complex Numbers and AC electrical systems

1.1 Complex numbers: a brief explainer

Equations without real solutions led to the development of the concept of complex numbers [1] p652 Chapter 12 Kreyzsig . For example, to solve for $x$ where $x^2 = -49$, we take the square root of both sides. However, $\sqrt{-49}$ is neither $-7$ nor $7$, as $(-7)^2 = 49$ and $7^2 = 49$. Similarly solving for $x$ where $x^2 = -27$, $\sqrt{-27}$ is not $3\sqrt{3}$ nor $-3\sqrt{3}$. Neither of these examples has a real solution.

To denote the imaginary component of the complex number which is the square root of $-1$, the standard notation in Mathematics is $i$. Therefore a complex number $z$ will be of a general form $x + iy$ where $x$ and $y$ are both real coefficients; in this case $y$ is a real coefficient of $i$, where $i$ is the imaginary component.

A complex number $z$ can also be expressed as an ordered pair $(x, y)$ of real numbers $x$ and $y$, written:

$z = (x, y) \hspace{10em} (1)$

$x$ is the real part and $y$ the imaginary part of the complex number $z$.

1.2 Notation for the complex number imaginary component used in Electrical Engineering

In contrast to the field of Mathematics, in Electrical Engineering, the letter $j$ is used in place of $i$ to denote the imaginary component of a complex number. As such that a standard form of complex number when described in Electrical Engineering terms, would be $x + jy$.

The basis for this change is that in Electrical Engineering, the standard symbol for current in a circuit is $i$, such that this symbol is ‘reserved’ and in order to avoid confusion, the imaginary component is instead defined to be $j$.

1.3 AC Electrical Systems: a quick primer

The term ‘AC’ (which originally stands for ‘alternating current’) can apply to any signal which regularly changes polarity over time. In practice, it will apply to any current or voltage signal. In addition, we can think of more complex signals as being made up of components an ‘AC’ and ‘DC’ component. The term ‘DC’ (which comes from ‘direct current’ originally) can be thought of as the non-time varying component of a signal, and the ‘AC’ the time varying component.

When we refer to AC electrical systems, we are dealing with sine or cosine based signals with no DC component of note. Any sinusoidally varying quantity (which we can arbitrarily define as a(t)) may be expressed as in equation 2.

$a(t) =\hat{A}\cos(\omega t + \theta_a)\hspace{6em} (2)$

where:

  • $\hat{A}$ is the amplitude or peak value of the cosine signal (a sinusoidal signal could also be used but by convention this is cosine)
  • $\theta_a$ is the initial phase angle (or offset angle) at a time of zero. This offset angle can also be equated to a time lag (delay) if negative, or a time lead if positive, denoted by the Greek letter ‘tau’ $\tau$.
  • $\omega$ the angular frequency, by convention measured in radians per second
  • $t$ is the time over which the waveform $a(t)$ is calculated

By convention the offset angle $\theta_a$ is expressed in radians; there are $2\pi$ radians in a complete circle of $360^{\circ}$, hence one radian is equal to $\frac{\pi}{180}$ degrees.

cosine signal showing peaks and amplitude, period and time delay
Figure 1: cosine signal $a(t)$ with time delay $\tau$ showing peak $\hat{A}$ and $A_{pk-pk}$ amplitude, period $T$
  • Frequency $f$ of the waveform is in units of cycles per second or Hertz (Hz)
  • Period $T$ is the period of time (s) taken for a waveform cycle

The frequency $f$, the period $T$ and the angular frequency $\omega$ are related as follows:

$ f = \frac{\omega}{2\pi} = \frac{1}{T} \rightarrow \omega = \frac{2\pi}{T}\hspace{6em} (3)$

The angle of the cosine waveform $\theta$ at time $t$ ($\theta_t$) is characterised by Equation (4) and from it you can see that after an initial offset of $\theta_a$, $\theta_t$ increases linearly with time:

$ \theta_t = \omega t + \theta_a \hspace{6em} (4)$

1.4 Python code for cosine signal with angle offset

The waveform described by Equation (2) is recreated in the Python code below:

# simple single phase AC cosinusoidal signal with angle offset/delay

import numpy as np

# Set cosine waveform parameters

# 50 Hz - frequency: number of complete rotations in a second
# 50 Hz is the standard fundamental frequency of power supplies in the UK
freq_hz = 50 

# waveform samples per fundamental waveform cycle
samples_per_cycle = 128 
# angular frequency (radians/s)
rad_sec = 2*np.pi*freq_hz 
no_cycles = 5 # number of full cycles

# waveform sample end time in seconds
end_time = no_cycles/freq_hz 

# sample frequency (fs)
sampling_freq = samples_per_cycle*freq_hz 

# total number of samples in the whole waveform example
no_samples = samples_per_cycle*freq_hz*no_cycles 

# create the time vector over which the waveform will be plotted
# np.linspace requires argument (min, max, num = no. increments)
# time vector 't' (in seconds)
t = np.linspace(0, end_time, num = no_samples) 
   
A_peak = 10
# initial phase offset/ time delay 
# time delay in seconds - denoted by tau
time_delay = -0.001 
phase_delay = time_delay*rad_sec

# a single phase signal 
A = A_peak*np.cos(rad_sec*t + phase_delay)

2. Cartesian, Polar and Exponential Forms of Complex Numbers

There are three forms in which Complex Numbers can be expressed:

Sections 2-5 walk you through the three Complex Number forms, and explains how one set is derived from another. You can skip the derivations if you wish, but they are included as a background resource to explain how a given complex number form can be created.

Ultimately of these three complex number forms, it is the Exponential form (section 5) which best describes the vector – a Phasor – which we can use to represent a sinusoidal ($sin$) or cosine ($cos$) waveform. Transformation of waveforms in the time domain into phasors is an incredibly useful tool in analysing AC electrical systems in steady state.

3. Cartesian Form of a Complex Number

The Cartesian complex number is one of the three ways of presenting a complex number; the cartesian form uses cartesian (rectilinear) coordinates.

A complex number in cartesian form is presented using rectilinear co-ordinates $(x,y)$ on a two dimensional real – imaginary (complex) plane. This two dimensional plane is also called an Argand Diagram. The point on the complex plane will be at the coordinates $(x,y)$. The axes are presented with the real part of the complex number $x$ along the x-axis, and the imaginary part $y$ along the y-axis ($j$), also expressed via equation (5).

$z= x + yj \hspace{6em} (5)$

An argand diagram that shows the 4 quadrants of a graph and presents examples of cartesian complex numbers
Figure 1: Argand Diagram used to represent a Cartesian Complex Number on a two dimensional complex plane.

Note that from Figure 1, any complex number $z=x+yj$ is represented as a two dimensional vector in the $x-y$ complex plane.

3.2 Python code: expression of cartesian complex numbers

In Python, cartesian complex numbers can be expressed using the Numpy package [2] https://numpy.org/doc/stable/reference/generated/numpy.imag.html . The complex number examples in Figure 1 are used in the Python code below:

import numpy as np

z1 = 3+3j
z2 = -5+1j
z3 = -3-4j
z4 = 3-3j
cart_complex_nos = np.array([z1, z2, z3, z4])

# print all the imaginary components
print(cart_complex_nos.imag)
# [ 3.  1. -4. -3.]

# print all the real components
print(cart_complex_nos.real)
# [ 3. -5. -3.  3.]

The inbuilt packages in Python can also handle complex numbers; it’s built in and it does not require installation via pip or to be imported:

# to use the complex function, no imports are required
  
# Initializing real coefficients as a list
# x1 = 3, y1 = 3, x2 = -5 ,y2 = 1, x3 = -3, y3 = -4, x4 = 3, y4 = -3
real_coeffs = [3, -5, -3, 3]
imag_coeffs = [3, 1, -4, -3]

# converting the x and y coefficients into complex numbers
complex_numbers = [complex(real, imag) for \
                   (real, imag) in zip(real_coeffs, imag_coeffs)]
print('list of complex nos: ', complex_numbers)
# list of complex nos:  [(3+3j), (-5+1j), (-3-4j), (3-3j)]

real_coefficients = [z.real for z in complex_numbers]
imag_coefficients = [z.imag for z in complex_numbers]

print('list of real coeffs: {}, list of imaginary coeffs: {}'\
      .format(real_coefficients, imag_coefficients))

# list of real coeffs: [3.0, -5.0, -3.0, 3.0], 
# list of imaginary coeffs: [3.0, 1.0, -4.0, -3.0]

4. Polar Form of a Complex Number

The polar form of a complex number is the second way of representing a complex number. It enables description of the complex number as a vector of length $r$ (‘r’ for radius of a circle) and $\theta$ which is the angle (conventionally in radians) which the vector makes with the real axis (x-axis), assuming anti-clockwise travel from the positive x-axis to the vector.

diagram showing the conversion of the cartesian form to the polar form
Figure 2: The Conversion of the Cartesian form to the Polar form.

The complex numbers in Figure 2 are vectors of length $r$ and their respective angle $\theta$ is the angle between the vector and the real axis.

4.1 Derivation: Polar Form from Cartesian Form

To derive the polar form, we can start with the Cartesian form and use trigonometry to convert this. Starting with Figure 2 and using trigonometric ratios, the following relationships shown in Equations (4) and (5) can be shown:

The magnitude (size, or length) of the vector $r$ is shown in Equation (6)

$r=\sqrt{x^2+y^2} \hspace{6em}(6)$

The counterclockwise angle of the vector from the positive real axis shown in Figure 2 is shown in equation (7)

$\theta = tan^{-1}(\frac{y}{x})\hspace{6em}(7)$

Using $cos$ and $sin$ trigonometry identities, we can obtain $x$ and $y$:

$x = r \cos(\theta) \hspace{6em} (8)$

$y = r \sin(\theta) \hspace{6em} (9)$

Substituting equations (7) and (8) into the Cartesian formula in equation (4) and factorizing for $r$ gives equation (10), which is the Polar Form of a complex number:

$z= r(\cos\theta + j \sin\theta)\hspace{4em} (10)$

By convention, the angle of a complex number when it is represented in polar form by a vector of a given length $r$ and a phase $\theta$, the angle is as measured anti-clockwise from the zero radians axis i.e. the positive real axis.

4.2 Python code: conversions between cartesian and polar formats

4.2.1 Cartesian to Polar form

import numpy as np
# deg=False sets angle to radian (default), deg=True, angle in degrees
# use np.angle and np.absolute
# complex numbers z1 to z4 from Figure 2
# built in numpy magnitude and phase

z1_to_z4 = [3+3j, -5+1j, -3-4j, 3-3j]

# Complex number phase - method 1 (numpy built in)
# counterclockwise angle from +ve real axis in the complex plane
# in the range (-pi, pi]

z1_to_z4_phase_radians = np.angle(z1_to_z4, deg=False)
print('z1_to_z4_phase in radians:', z1_to_z4_phase_radians)
# z1_to_z4_phase in radians:
# [ 0.78539816  2.94419709 -2.21429744 -0.78539816]

z1_to_z4_phase_degrees = np.angle(z1_to_z4, deg=True)
print('z1_to_z4_phase in degrees:', z1_to_z4_phase_degrees)
# z1_to_z4_phase in degrees:
# [  45.     168.69006753 -126.86989765  -45.        ]

# Complex number magnitude - method 1 (numpy built in)

# np.abs and np.absolute are completely equivalent
z1_to_z4_magnitude_numpy = np.absolute(z1_to_z4)
print('z1_to_z4_magnitude calculated by numpy package',
      z1_to_z4_magnitude_numpy)

# z1_to_z4_magnitude calculated by numpy
# package [4.24264069 5.09901951 5.      4.24264069]

Converting to polar form (magnitude and phase) via non NumPy methods:

# (x, y) coefficients for 4 complex numbers - (x1,y1)...(xn, yn)
real_coeffs = [3, -5, -3, 3]
imag_coeffs = [3, 1, -4, -3]

real_coeffs_array = np.array(real_coeffs)
imag_coeffs_array = np.array(imag_coeffs)

# Complex number phase - method 2 (numpy)
# np.arctan gives the four quadrant angle (phase).
# 4 quadrant is 0-2pi (expressed -pi to +pi)

# # Complex number phase - method 2 (arctan2)
# z1 to z4 in radians
z1_z4 = np.arctan2(imag_coeffs_array, real_coeffs_array)

print('z1 to z4 angles (radians)', z1_z4)
# z1 to z4 angles (radians)
# [ 0.78539816  2.94419709 -2.21429744 -0.78539816]

# z1 to z4 in degrees
z1_z4_degrees = np.arctan2(imag_coeffs_array,\
                           real_coeffs_array) * 180 / np.pi

print('z1 to z4 angles (degrees)', z1_z4_degrees)
# z1 to z4 angles (degrees) 
#[  45.          168.69006753 -126.86989765  -45.        ]

# calculate magnitude - Method 2
calculate_magnitude = lambda x,y: np.sqrt(x**2 + y**2)
z1_z4_magnitudes = calculate_magnitude(real_coeffs_array,
                                       imag_coeffs_array)

print('z1_z4_magnitudes:', z1_z4_magnitudes)
# z1_z4_magnitudes: [4.24264069 5.09901951 5.    4.24264069]

4.2.2 Polar to Cartesian form

In order to transform the polar form back to the cartesian form, the following code uses Equation (8) and Equation (9) to recover the cartesian components from the polar ones:

# converting back from Cartesian to Polar form
import numpy as np
# calculating original real and imaginary components from 

z1_z4_angles = [ 0.78539816,  2.94419709, -2.21429744, -0.78539816]
z1_z4_magnitudes =  [4.24264069, 5.09901951, 5.,  4.24264069]

# create anonymous functions to calculate real and imaginary
# cartesian components
# theta is in radians, not degrees

calc_real_components = lambda r,theta: r*np.cos(theta)
calc_imag_components = lambda r,theta: r*np.sin(theta)

# apply anonymous functions to numpy arrays or lists

real_components = calc_real_components(z1_z4_magnitudes,
                                       z1_z4_angles)
imag_components = calc_imag_components(z1_z4_magnitudes,
                                       z1_z4_angles)

print('real components {}, imaginary components {}'
      .format(real_components, imag_components))

# real components [ 3.00000001 -4.99999999 -3.00000002  3.00000001],
# imaginary components [ 2.99999999  1.00000002 -3.99999999 -2.99999999]

Note from the output of code (the real components and imaginary components) are, subject to rounding errors, we can recover the original cartesian $x, y$ component values listed in Figure 2.

5. Exponential Form of a complex number (Euler’s Identity)

Euler’s identity or Euler’s formula – the secret sauce! – is shown in Equation (11) and is the third alternative representation of a complex number $z$ in the complex plane:

$ z = re^{j\theta} = r(\cos{\theta}+j\sin{\theta}) \hspace{4em} (11)$

The relationship described by Equation (11) is derived in full in section 5.1, but if you would rather just use the result in Equation 11, skip to section 5.2.

5.1 Derivation: Exponential Form from Polar Form

5.1.1 The Taylor Series Expansion

The Taylor Series is a power series expansion of any real function $f(x) about a particular point [3] https://mathworld.wolfram.com/TaylorSeries.html . The power series provides a representation of the function $f(x)$ which all terms are non negative integer powers of the variable.

For example, if we have some function $f(x)$, where $x=c$, where $c$ is an arbitrary constant and our particular input of interest. The output value of our function is evaluated at that point $c$ is calculated to be $f(c)$, in other words, the function $f$ where $x = c$. We begin by assuming that we can let $f(x)$ be represented by a power series:

The value of a function $f(x)$ at point $c$ approximated up to $n$ terms, is given by equation (12), where:

  • $a_n$ is a series of coefficients,
  • $n!$ is a factorial. For example, $4! = 1*2*3*4 = 24$
  • $f^{(n)}(a)$ is the $n^{th}$ derivative of $a$,

$ f(x) = \sum_{n=0}^\infty a_n(x-c)^n = a_0 +a_1(x-c) + a_2(x-c)^2 + a_3(x-c)^3 + …+a_n(x-c)^n (12)$

We do not have values for the coefficients $a_0, a_1, a_2, a_3…a_n$, and therefore need to find a way of calculating them. To calculate the coefficients, we take the original power series for $f(x)$ and its derivatives, and each case substitute $x = c$ into the power series. This yields the values for $f(x), f'(x), f”(x)$ (left column), and $f(c), f'(c), f”(c)$ (right column), as shown in Table 1.

$ f(x) = a_0 +a_1(x-c) + a_2(x-c)^2 + a_3(x-c)^3 +a_4(x-c)^4 ..+a_n(x-c)^n$$f(c) = a_0$
$f'(x) = 0 +a_1 +2a_2(x-c) +3a_3(x-c)^2 + 4a_4(x-c)^3..+n a_n(x-c)^{n-1}$$f'(c) = a_1$
$f^{(2)}(x) = 0 + 0 +2a_2 +6a_3(x-c) + 12a_4(x-c)^2..+n(n-1) a_n(x-c)^{n-2}$$f^{(2)}(c) = 2a_2$
$f^{(3)}(x) = 0 + 0 + 0 + 6a_3 + 24a_4(x-c)..+n(n-1)(n-2) a_n(x-c)^{n-3}$$f^{(3)}(c) = 6a_3$
Table 1: The Taylor Series representation of $f(x)$ and its first, second and third derivatives (left column), with values where $x=c$ (right column)

From Table 1, the right hand column, it can be observed that the coefficient of $a_n$ is a factorial of the derivative; for example, for $f^{(3)}(c)$, the coefficient is $6$ which is $3!$. When the coefficients $a_0, a_1, a_2…a_n$ are substituted into equation (12), they give rise to equation (13):

$ f(x) = f(c) + f'(c)(x-c)+\frac{f”(c)}{2!}(x-c)^2+\frac{f^{(3)}(c)}{3!}(x-c)^3+…+\frac{f^{(n)}(c)}{n!}(x-c)^n \hspace{4em}(13)$

Note that the Taylor Series is an infinite series (the number of terms calculated can go on for ever), but it can be used practically to provide an approximation of the value of any (real) function at a particular chosen point, $x=c$. The more terms of the Taylor Series which are calculated, provided that the series is capable of convergence, the closer the power series approximation of the function is to its true value.

5.1.2 The MacLaurin Series Expansion

The MacLaurin Series Expansion is a special case of the Taylor Series Expansion, where the coefficient $c$ referred to in the Taylor Series Expansion is set to zero, i.e. $c=0$. This MacLaurin series Equation (13), simplifies to be Equation (14):

$ f(x) = f(0) + f'(0)x+\frac{f”(0)}{2!}x^2+\frac{f^{(3)}(0)}{3!}x^3 + \frac{f^{(4)}(0)}{4!}x^4 …+\frac{f^{(n)}(0)}{n!}x^n\hspace{4em}(14)$

There are MacLaurin series for $sin(x)$, $cos(x)$ and $e^x$ and these are explained and defined below:

5.1.2.1 Maclaurin Series of $cos(x)$

By taking the derivative of each term gives us the Taylor series for cosine:

$f(x) = cos (x)$$f(0) = cos (0) = 1$$n=0$
$f'(x) = – sin (x)$$f'(0) = – sin (0) = 0$$n=1$
$f^{(2)}(x) = – cos (x)$$f^{(2)}(0) = – cos (0) = -1$$n=2$
$f^{(3)}(x) = sin (x)$$f^{(3)}(0) = sin (0) = 0$$n=3$
$f^{(4)}(x) = cos (x)$$f^{(4)}(0) = cos (0) = 1$$n=4$
$f^{(5)}(x) = -sin(x)$$f^{(5)}(0) = – sin (0) = 0$$n=5$
Table 2: The Taylor Series representation of $f(x) = cos(x)$ and its first, second and third derivatives (1st column), with values where $x=0$ (2nd column)

Using Equation (14) and the values from Table 2, yields Equation (15):

$ f(x) = cos(x) = \frac{1}{0!}x^0 + 0 -\frac{1}{2!}x^2 + 0 + \frac{1}{4!}x^4 + 0…\hspace{4em}(15)$

Note that $0! = 1$. This Equation (15) can be expressed in compact form as Equation (16):

$cos(x)=\sum_{n=0}^\infty = \frac{(-1)^n}{(2n)!}x^{2n}\hspace{4em}(16)$

5.1.2.2 Maclaurin Series of $sin(x)$

$f(x) = sin (x)$$f(0) = sin (0) = 0$$n=0$
$f'(x) = cos(x)$$f'(0) = cos(0) = 1$$n=1$
$f^{(2)}(x) = – sin(x)$$f^{(2)}(0) = – sin(0) = 0$$n=2$
$f^{(3)}(x) = – cos (x)$$f^{(3)}(0) = -cos (0) = -1$$n=3$
$f^{(4)}(x) = sin (x)$$f^{(4)}(0) = sin (0) = 0$$n=4$
$f^{(5)}(x) = cos (x)$$f^{(5)}(0) = cos (0) = 1$$n=5$
Table 3: The Taylor Series representation of $f(x) = sin(x)$ and its first, second and third derivatives (1st column), with values where $x=0$ (2nd column)

Using Equation (14) and the values from Table 3, yields Equation (17):

$ f(x) = sin(x) = 0 + \frac{1}{1!}x + 0 + \frac{-1}{3!}x^3 + 0 + \frac{1}{5!}x^5…\hspace{4em}(17)$

More compactly, the $sin(x)$ series is represented by expression (18):

$sin(x)$ = $\sum_{n=0}^\infty = \frac{(-1)^n}{(2n+1)!}x^{2n+1} \hspace{4em}(18)$

5.1.2.3 Maclaurin Series of $e^x$

If $f(x) =e^x$, $f'(x) = e^x$, $f^{(2)}e^x = e^x$. Therefore all the further derivatives $e^x$ are equal to $e^x$. When $x = 0$, $f(x) =e^0=1$. Therefore, all coefficients of the series from equation (14) are equal to 1, and the Maclaurin series for $e^x$ is shown in Equation (19):

$e^x = 1+x+\frac{x^2}{2! }+ \frac{x^3}{3!} + \frac{x^4}{4!}+…\hspace{4em}(19)$

5.1.2.4 Linking the series: $e^x$, $sin(x)$ and $cos(x)$

In equation (19), substitute $x$ with $j\theta$, to give equation (20):

$e^{j\theta} = 1+ j\theta +\frac{(j\theta)^2}{2!}+\frac{(j\theta)^3}{3!}+\frac{(j\theta)^4}{4!}+…\hspace{6em}(20)$

Expanding equation (20), equation (20) can be simplified to yield equation (21):

$e^{j\theta} = 1+j\theta+\frac{j^2\theta^2}{2!}+\frac{j^3\theta^3}{3!}+\frac{j^4\theta^4}{4!}+…\hspace{6em}(21)$

Taking into account that $j^2 = -1$, equation (21) can be simplified to give equation (22):

$e^{j\theta} = 1+j\theta-\frac{\theta^2}{2!}-\frac{j\theta^3}{3!}+\frac{\theta^4}{4!}+…\hspace{6em}(22)$

Real and imaginary terms from equation (22) can be grouped as shown in equation (23):

$e^{j\theta} =(1-\frac{\theta^2}{2!}+\frac{\theta^4}{4!}-…) + j(\theta-\frac{\theta^3}{3!}+\frac{\theta^5}{5!}-…)\hspace{6em}(23)$

Substituting $x$ for $\theta$ in both the Maclaurin series for $cos(x)$ (equation 15) and Maclaurin series for $sin(x)$ (equation 17) and comparing those two equations with equation (23), gives the relationship in equation (24):

$e^{j\theta}=cos\theta+jsin\theta \hspace{6em}(24)$

Note that both sides of equation (24) are always equal to 1, irrespective of the value of $\theta$, such that as $\theta$ changes in the range of $0-2\pi$, the expression trace a unit circle of radius 1.

From equation (11), the composite polar form expression for a complex number $z$, is $z= r(\cos{\theta}+j\sin{\theta})$ [4] pg. 440-441 of Engineering Mathematics – K.A. Stroud with additions by Dexter J.Booth . From equation (24), we can replace the $\cos\theta+j\sin\theta$ with $e^{j\theta}$. This leaves the simplified Euler’s formula, shown in Equation (19), identical to equation (6):

$z=r e^{j\theta} = r(cos\theta + j sin\theta) \hspace{6em}(19)$

Python conversions between the polar and exponential complex forms are shown in the next section 5.2.

5.2 Python code: conversions between polar and exponential

5.2.1 Polar to Exponential

The polar form can be converted to an exponential form using the calculated magnitude $r$ and phase $\theta$ from Equation (19). This code snippet uses Python’s inbuilt cmath package to calculate the exponential form, but note that it displays the complex numbers in Cartesian form:

import cmath
# Using polar form magnitudes and phases of z1 to z4 from previous example

z1_z4_angles = np.array([ 0.78539816,  2.94419709, -2.21429744, -0.78539816])
z1_z4_magnitudes =  np.array([4.24264069, 5.09901951, 5.,  4.24264069])

# calculate the exponential form using r (magnitude), theta (phase)
polar2exponentialcmath = lambda r,theta: r*cmath.exp(1j * theta)

z1_z4_exponential_cmath = [polar2exponentialcmath(magnitude, angle) for \
                   (magnitude, angle) in zip(z1_z4_magnitudes, z1_z4_angles)]

print('z1 to z4 exponential form using python cmath', z1_z4_exponential_cmath)
# z1 to z4 exponential form using python cmath 
# [(3.000000012229318+2.9999999918446276j),
# (-4.999999992737072+1.00000001799496j), (-3.000000017647277-3.9999999867645424j),
# (3.000000012229318-2.9999999918446276j)]

Similarly, the conversion of Polar to Exponential can be carried out using NumPy (which calculates the Euler form but outputs the result in Cartesian format):

import numpy as np
# np.exp is the exponent - a number to the base 'e'

z1_z4_angles = np.array([ 0.78539816,  2.94419709, -2.21429744, -0.78539816])
z1_z4_magnitudes =  np.array([4.24264069, 5.09901951, 5.,  4.24264069])

polar2exponential = lambda r,theta: r*np.exp(1j * theta)

z1_z4_exponential = polar2exponential(z1_z4_magnitudes, z1_z4_angles)

print('z1 to z4 exponential form with np', z1_z4_exponential)
# z1 to z4 exponential form with np [ 3.00000001+2.99999999j 
# -4.99999999+1.00000002j
# -3.00000002-3.99999999j  3.00000001-2.99999999j]

5.2.1 Exponential to Polar

When the Exponential (Euler) form is transformed back to Polar, and the polar form is printed, the first array contains the modulus (or magnitude or length) of the polar vector, and the second array shows its angle (phase) in radians measured against the positive real axis:

import numpy as np
# abs (absolute value or modulus/magnitude/length), 
# angle (angle when in polar form which is made with the positive real axis)

# standard function - Euler (or cartesian!) form to polar
def euler2polar(z):
    return (np.abs(z), np.angle(z))

# anonymous function equivalent of Euler form to polar
eulerform2polar = lambda z: (np.abs(z), np.angle(z))

# re-stating the angles and magnitudes calculated above z1 - z4
z1_z4_angles = np.array([ 0.78539816,  2.94419709, -2.21429744, -0.78539816])
z1_z4_magnitudes =  np.array([4.24264069, 5.09901951, 5.,  4.24264069])

# re-running exponential form of z1 - z4 
polar2exponential = lambda r,theta: r*np.exp(1j * theta)
exponential_z1_z4 = polar2exponential(z1_z4_magnitudes, z1_z4_angles)

# taking exponential form back to Polar
eulerform2polar = lambda z: (np.abs(z), np.angle(z))
z1_z4_polar = eulerform2polar(exponential_z1_z4)

print('z1 to z4 polar', z1_z4_polar)
# z1 to z4 polar (array([4.24264069, 5.09901951, 5.        , 4.24264069]),
# array([ 0.78539816,  2.94419709, -2.21429744, -0.78539816]))

6. Connecting complex number concepts to cosine steady state circuit analysis

6.1 Complex Numbers as a function of phase angle

In order to connect complex number concepts to sinusoidal or co-sinusoidal steady state circuits, we start with Equation (6) or its identical Equation (19): $z=r e^{j\theta} = r(cos\theta + j sin\theta)$, showing the equivalent polar and exponential complex forms.

Making the following substitutions into Equation (19): substituting in $\theta_t$, angle of the cosine waveform at time $t$, for $\theta$, and replacing the modulus (length) of $r$ with it equivalent ‘length’ i.e. the amplitude of the peak of the cosine signal $\hat{A}$, gives the complex expression in terms of modulus $\hat{A}$, and phase at a given time $\theta_t$:

$ z = \hat{A}e^{j\theta_t} = \hat{A}(\cos{\theta_t}+j\sin{\theta_t}) \hspace{4em} (20) $

The above equation gives the complex expression in terms of $\theta_t$ which will represent a waveform’s amplitude $\hat{A}$ and phase $\theta_t$ over time, as it rotates around the origin $(0,0)$ of an Argand diagram (in the complex $x, y$ plane) anticlockwise as time $t$ increases. At this point, the expression does not include information as to the rate of rotation.

In the next section, the complex number is expressed in terms of angular frequency, $\omega$ which provides additional information as to how quickly the complex ‘vector’ (Phasor) is rotating.

6.2 Complex Numbers as a function of angular frequency

As defined in Section 1.3, angular frequency is expressed in terms of $\omega$. Substituting the expression in equation (4), $\theta_t = \omega t + \theta_a$, into equation (20), gives equation (21):

$\hat{A} e^{j(\omega t +\theta_a)} = \hat{A}[\cos(\omega t + \theta_a) +j \sin(\omega t + \theta_a)]\hspace{6em} (21)$

Equation (23) now completely describes the complex expression in terms of the peak of the signal $\hat{A}$, its initial phase angle $\theta_a$, angular frequency $\omega$ and time $t$.

The function is complex with a magnitude (or a modulus) that is equal to $\hat{A}$. The phase (angle, or argument) of the waveform increases linearly with time $t$ at a rate of $\omega$. When $t=0$, the argument (or phase, or angle) is $\theta_a$ as measured against the positive real axis, and plotted on an Argand diagram it rotates anti-clockwise at a rate of $\omega$ radians per second about the origin $(0,0)$ as time $t$ increases. The next section will relate the complex expression with the time domain of the original cosine signal from Equation (3).

6.3. Equating complex and time domains for AC circuits

In order to relate the complex expression in Equation (21) to actual time domain signals such as current or voltage(Equation (3)), you must take the real part of Equation (21). Therefore, this gives Equation (22) which is the projection of the onto the real axis $a(t) =\hat{A}\cos(\omega t + \theta_a)$:

$\hat{A}\cos(\omega t + \theta_a) = Re(\hat{A} e^{j(\omega t +\theta_a)})\hspace{6em} (22)$

The imaginary part of the complex signal is:

$\hat{A}j\sin(\omega t + \theta_a) = Im(\hat{A} e^{j(\omega t +\theta_a)})\hspace{6em} (23)$

Therefore at time $t=0$, in the time domain the waveform will have the value of $\hat{A}\cos(\theta_a)$ and if $\theta_a = 0$, the initial value of the waveform in the time domain is $\hat{A}$ as $cos\theta = 1$.

6.3.1 Complex valued functions and phasors

$a(t) = \hat{A} e^{j(\omega t +\theta_a)} = \hat{A} e^{j\theta_a}e^{j\omega t}\hspace{6em} (24)$

The amplitude and phase of the cosinusoidal signal $a(t)$ equation (24) above can be specified by a simplified complex number $ \bar{A} = \hat{A} e^{j\theta_a}$. Note that in order to ignore the $\omega t$ term, we assume that the signal and the circuit in which it occurs, is operating in an AC steady state with constant angular frequency $\omega$.

A compact representation of magnitude and phase (angle) of the phasor $re^{j\theta}$ is in equation (25):

$z=r\angle\theta \hspace{6em}(25)$

Likewise, the phasor which represents the cosinusoidal signal, would be compactly represented by equation (26):

$z=\hat{A}\angle\theta_a \hspace{6em}(26)$

7. Conclusions

This tutorial has set out the background and derivations for the various forms of complex number, and how they relate to one another and to AC electrical engineering systems. These fundamentals can be used to calculate (in later tutorials) circuit reactances and impedances, explain phase shifts if any in AC steady state arising from the behaviour of passive components (inductive, capacitive and resistive elements).

References

References
1 p652 Chapter 12 Kreyzsig
2 https://numpy.org/doc/stable/reference/generated/numpy.imag.html
3 https://mathworld.wolfram.com/TaylorSeries.html
4 pg. 440-441 of Engineering Mathematics – K.A. Stroud with additions by Dexter J.Booth
We hope you find this tutorial useful, please share it if you do!