Complex Numbers#

The history of mathematics is a rich tapestry of discoveries and inventions. The Greeks, fascinated by geometry, introduced both natural and rational numbers but, intriguingly, neglected to incorporate negative numbers or zero. Their experiences and understanding of the world, their perspectives on points, lines, and shapes – grounded in classical Euclidean geometry—kept these concepts hidden. Negative lengths or areas were unheard of. They also seemed aware that there might be another category of number—the irrational numbers—beyond the rational. Legend has it that a student of Pythagoras stumbled upon this notion, asserting that something other than rational numbers must exist for the existing mathematical theories to hold true. His audacity cost him his life.

As the world evolved, so did mathematical concepts. The advent of sophisticated financial systems, underscored by the principles of credit and debt, gave birth to the concept of negative numbers. After all, the balance between debt and credit necessitated the existence of a counterpart to a positive number in terms of addition.

We rely on natural numbers to solve equations like 2x=4. We require negative numbers for equations like 2x=4, rational numbers for equations such as 4x=2, and real numbers to tackle equations like x2=2. So, how do we approach the solution for

(2)#x2+2=0?

We require complex numbers. These numbers extend real numbers by definition, but their definition is not arbitrary. Instead, it has been meticulously crafted so that complex numbers possess all necessary properties to be integrated into all known and accepted theories. To define complex numbers, we introduce a special symbol i (some prefer to use j), which is defined as follows imaginary number:

(3)#i2:=1.

We can define i in a self-referential manner and it was Spencer-Brown [SB69] who thought about such paradoxical definitions as generator:

i1/i.

Assuming, we initialize i with one, this generator would generate the following oscillation: 1,1,1,1, which is an interesting perspective. However, in general, we just use the static definition above without the need for the involvement of time. Again, complex numbers are invented but they are also discovered because everything works out, i.e., they have all the rich mathematical properties we desire and require. Let us solve Eq. (2):

x2=2=2i2x=2i2=2i2=2i

sclang provides a class called Complex. Objects of that class represent complex numbers. Let us solve Eq. (2) with sclang:

n = Complex(real: -2, imag: 0) // -2
x = sqrt(n)                    // i*sqrt(2)

For complex numbers to be useful, they must be compatible with real numbers. For instance, what does the expression i+3 represent, where i is a complex number and 3 is a real number?

Complex Numbers

A complex number

(4)#z=(a+bi)C,

with i=1, is the sum of a real number a=Re(z)R and an imaginary number b=Im(z).

A complex number z has two parts: a real real and an imaginary imag part. Note that squaring an imaginary number gives a real number, i.e. (bi)2=1b2=b2. Furthermore, we get 0=0+0i, bi=0+bi, a=a+0i.

Equality, addition, multiplication and negation works as expected. There is however an additional special operation called complex conjugation.

Complex Conjugation

The conjugation z of a complex number z=a+bi is the negation of its imaginary part, i.e.,

(5)#z=a+bi=a+bi=abi.
n = Complex(real: 2, imag: 9)
n.conjugate // Complex(real: 2, imag: -9)
n.conjugate * n // Complex(real: 85, imag: 0)

Multiplying a complex number z=a+bi by its conjugate gives us a real number:

zz=(a+bi)(abi)=a2(bi)2=a2+b2.

We can use this fact to evaluate the division of two complex numbers z1=a+bi,z2=c+di:

a+bic+di=(a+bi)(cdi)(c+di)(cdi)=acadi+bic+bdi2c2+d2=(ac+bd)+(bcad)ic2+d2.

For example:

2+i3+2i=(2+i)(32i)(3+2i)(32i)=64i+3i2i232+22=8i13.
Complex(2, 1) / Complex(3, 2)

Complex Plane#

We can represent a complex number z=a+bi by a point (a,b) in the Cartesian plane, which we then call complex plane or z-plane.

../../../_images/bfb3417f199e4e818a93f6e79eecefebad66e45c8aaa03fa53b9a259f14c3f8e.png

This gives us another representation using the angle ϕ and the magnitude r of the vector (a,b). We have

(6)#a=rcos(ϕ)bi=risin(ϕ)

thus

(7)#z=a+bi=(rcos(ϕ))+(risin(ϕ))=r(cos(ϕ)+isin(ϕ)).

We write z=(r,ϕ), z=a+bi, z=r(cos(ϕ)+isin(ϕ)) interchangeable. Given a and b, we can compute r by

(8)#r2=a2+b2=zz

and ϕ using

(9)#ϕ=cos1(a/r).

Furthermore we can compute ϕ if only a and b are given using the arctan2 function

(10)#ϕ=arctan2(b,a).
(
var theta = 0.25*pi;
var z = Complex(cos(theta), sin(theta));
theta.postln;      // 0.78539816339745
z.postln;          // Complex( 0.70710678118655, 0.70710678118655 )
z.asPolar.postln;  // Polar( 1.0, 0.78539816339745 )
)

What happens geometrically if we multiply two complex numbers? If one of the numbers is a real number, we just scale the magnitude.

Let z1=r1(cos(α)+isin(α)) and z2=r2(cos(β)+isin(β)) then

(11)#z1z2=r1(cos(α)+isin(α))r2(cos(β)+isin(β))=r1r2(cos(α)cos(β)+icos(α)sin(β)+isin(α)cos(β)+i2sin(α)sin(β))=r1r2[(cos(α)cos(β)sin(α)sin(β))+i(cos(α)sin(β)+sin(α)cos(β))]=r1r2[cos(α+β)+isin(α+β)].

The last step requires the trigonometry identities

cos(α)cos(β)sin(α)sin(β)=cos(α+β)

and

cos(α)sin(β)+sin(α)cos(β)=sin(α+β).

Eq. (11) gives us some insights. The product of two complex numbers equates to scaling and rotating by magnitude and angle of the second number respectively.

Product of Complex Numbers

The product of two complex numbers is the product of their magnitudes and the sum of their angles.

Since i=1(acos(90)+isin(90)) holds, multiplying by i equates to a counterclock rotation by 90 degrees. Since i=1(acos(90)isin(90))=1(acos(90)+isin(90)), dividing by i equates to multiplying by i thus

1i=i

and

1i1i=(i)(i)=1.

From the rule of products of complex numbers de Moivre’s Theorem follows.

De Moivre’s Theorem

Let z=r(cos(ϕ)+isin(ϕ)) be a complex number, then

(12)#zn=rn(cos(nϕ)+isin(nϕ))

holds.

Euler’s Formula#

Euler’s formula or Euler’s equation is one of the most beautiful relationships one can think of. It connects Euler’s number e, 0, 1 and π. To arrive at the formula we first have to do some work.

Taylor Sries

Let y(t) be a real or comlex-valued function that is infinitely differentiable at a real or complex number z, then

(13)#Ty(z)(t)=y(z)+y(z)1!(tz)+y(z)2!(tz)2+y(z)3!(tz)+=k=0y(k)(z)k!(tz)=y(t)

is the Taylor series of y(t) at t=z. If z=0 the series is also called Maclaurin series.

One often approximates a function using only the initial terms of Taylor’s series. What we require are the Taylor series for sine, cosine, and the natural exponential functions. We know that

sin(t)=cos(t) and cos(t)=sin(t).

Furthermore,

sin(0)=0 and cos(0)=1.

Therefore, we get

(14)#sin(t)=Tsin(0)(t)=k=0sin(k)(0)k!(t)=0+t0t33!+0+t55!0t77!+=tt33!+t55!t77!+

for the sine function.

../../../_images/taylor_sin.png

Fig. 13 Taylor series that approximates sin(x) at x=0 using 1,2,3,4,5 terms.#

And we get

(15)#cos(t)=Tcos(0)(t)=k=0cos(k)(0)k!(t)=10t22!+0+t44!0t66!+=1t22!+t44!t66!+

for the cosine function.

../../../_images/taylor_cos.png

Fig. 14 Taylor series that approximates cos(x) at x=0 using 1,2,3,4,5 terms.#

Furthermore, the natural exponential function has a quite nice form too, that is,

(16)#et=Te0(t)=k=0exp(k)(0)k!tk=k=0tkk!

since exp(k)(t)=exp(t) for all kN0 and e0=1. Note that we donte et by exp(t).

../../../_images/taylor_exp.png

Fig. 15 Taylor series that approximates ex at x=0 using 1,2,3,4,5 terms.#

What happens if we plug in an imaginary number like ϕi, with ϕR? Well let’s see:

eϕi=Te0(ϕi)=k=0(ϕi)kk!=1+ϕi1!+ϕ2i22!+ϕ3i33!+ϕ4i44!+ϕ5i55!+ϕ6i66!=1+ϕi1!ϕ22!ϕ3i3!+ϕ44!+ϕ5i5!ϕ66!=(1ϕ22!+ϕ44!ϕ66!+)+i(ϕ1!ϕ33!+ϕ55!)=cos(ϕ)+isin(ϕ).

We arrive at Euler’s formula which links the hyperbolic functions, involving e, to trigonomeitric functions, involving π!

Euler’s Formula

Let iϕ be an imaginary number, then

(17)#eiϕ=cos(ϕ)+isin(ϕ)

holds. This relation is called Euler’s formula.

exp(Complex(0, pi/3)) == Polar(1, pi/3).asComplex // true

We can immidiatly follow that

eiπ=cos(π)+isin(π)=1+i0=1.
exp(Complex(0, pi)) + 1 < 0.00001  // true
exp(Complex(0, pi)) + 1 > -0.00001 // true

Therefore, the most beautiful formula of all times, called Euler’s identity, emerges

(18)#eiπ+1=0.

Looking at Eq. (17) we immediately see that

(19)#ωR:|eiω|=1

holds. Therefore,

z=eiω|zk|=1.

I illustrate this fact by using z=ei2πN, i.e. ω=2πN and the following plot, where the plotted points are defined by

zk=ei2πNk for k=0,1,2,N1 with N=19.

All points lie on the red unit circle.

../../../_images/0f92c48a7e980137d522e9c9aacf8b03addeac9e93c8a4913dc30509c06ddfac.png

Furthermore, we can see that the discrete function g(k):ZC, g(z)=zk is periodic and that its period is N:

g(N+1)=(ei2πN)N+1=ei2π(N+1)N=ei2πei2πN=ei0ei2πN=1ei2πN=z=g(1).

If |z| would be greater than 1, then zk would grow to infinity and if |z|<1, it would converge to 0.

Using Euler’s formula, i.e. Eq. (17), we can represent our well-known trigonometric functions by exponential functions. We start with

(cos(ϕ)+isin(ϕ))+(cos(ϕ)isin(ϕ))=2cos(ϕ)=eiϕ+eiϕ.

Therefore, we get

(20)#cos(ϕ)=eiϕ+eiϕ2.

For the sine, we start with

(cos(ϕ)+isin(ϕ))(cos(ϕ)isin(ϕ))=2isin(ϕ)=eiπeiπ.

Therefore, we get

(21)#sin(ϕ)=eiϕeiϕ2i=ieiϕeiϕ2.

Phasors#

Interestingly, by using Euler’s formula, we can encode the phase and amplitude of a sinosoid by one very compact representation which we call phasor.

Phasor

A phasor is the polar representation of any complex variable

(22)#r^ϕ=reiϕ,

where r,ϕR. It represents the amplitude and phase shift of some sinosoid.

We can define any sinosoid of the form

(23)#y(t)=rcos(2πft+ϕ)

using the only the real part of

(24)#r^ϕphasorei2πftcircular motion=reiϕei2πft=rei(2πft+ϕ)=r(cos(2πft+ϕ)+isin(2πft+ϕ))=y(t)+irsin(2πft+ϕ)),

where the phasor r^ϕ=reiϕ is a constant, f is the frequency, and ϕ the phase of the sinusoid. The phasor r^ϕ tells us everything about the amplitude and the phase ϕ of the signal y(t).

In many text books you will find

(25)#rei(ωt+ϕ)=r(cos(ωt+ϕ)+isin(ωt+ϕ))=y(t)+irsin(ωt+ϕ))

instead, where ω=2πf is the anglar speed or speed of rotation.

../../../_images/phasor_function.jpeg

Fig. 16 A complex sinusoid y(t)=rei(2πft+ϕ). The phasor is the first red point, i.e. y(0).#

Remember, we can represent any audio signal as a sum of sinusoids. Since each phasor is also a vector, a sinusoid comprising multiple frequencies can be represented as a sum of phasors.

../../../_images/phasor_complex_function.jpeg

Fig. 17 A complex sinusoid y(t) defined by 3 phasors and 3 differen frequencies.#