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
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
We can define
Assuming, we initialize
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
A complex number real
and an imaginary imag
part.
Note that squaring an imaginary number gives a real number, i.e.
Equality, addition, multiplication and negation works as expected. There is however an additional special operation called complex conjugation.
Complex Conjugation
The conjugation
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
We can use this fact to evaluate the division of two complex numbers
For example:
Complex(2, 1) / Complex(3, 2)
Complex Plane#
We can represent a complex number
This gives us another representation using the angle
thus
We write
and
Furthermore we can compute
(
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
The last step requires the trigonometry identities
and
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
and
From the rule of products of complex numbers de Moivre’s Theorem follows.
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
Taylor Sries
Let
is the Taylor series of
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
Furthermore,
Therefore, we get
for the sine function.

Fig. 13 Taylor series that approximates
And we get
for the cosine function.

Fig. 14 Taylor series that approximates
Furthermore, the natural exponential function has a quite nice form too, that is,
since

Fig. 15 Taylor series that approximates
What happens if we plug in an imaginary number like
We arrive at Euler’s formula which links the hyperbolic functions, involving
Euler’s Formula
Let
holds. This relation is called Euler’s formula.
exp(Complex(0, pi/3)) == Polar(1, pi/3).asComplex // true
We can immidiatly follow that
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
Looking at Eq. (17) we immediately see that
holds. Therefore,
I illustrate this fact by using
All points lie on the red unit circle.
Furthermore, we can see that the discrete function
If
Using Euler’s formula, i.e. Eq. (17), we can represent our well-known trigonometric functions by exponential functions. We start with
Therefore, we get
For the sine, we start with
Therefore, we get
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
where
We can define any sinosoid of the form
using the only the real part of
where the phasor
In many text books you will find
instead, where

Fig. 16 A complex sinusoid
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.

Fig. 17 A complex sinusoid