01 Matika
01 Matika
for ISS
Honza Černocký, ÚPGM FIT VUT
1
Functions and sequences
• Signals with continuous time (analog, real world) are defined for all
times t. Signály se spojitým časem, spojité signály.
• From math point of view, they are functions x(t) round brackets
• Signals with discrete time (computer, digital world), sampled signals
are defined only for integer times (sample numbers) n. Signály s
diskrétním časem, diskrétní signály, vzorkované signály.
• From math point of view, they are sequences x[n] square brackets.
2 / 35
How is it done in Python ? Just 4 steps …
1. Generate the independent variable - 1 line of Python code
2. Generate or read the signal - 1 line of Python code
3. Do something with the signal - 1 line of Python code
4. Show the result - 1 line of Python code (or more if you want to have
it nice)
3 / 35
Operations with functions
• As you know them from primary school, just do it for all times:
• Addition
• Subtraction
• Multiplication
• Mind the “masking effect” of zeros
#basicops
4 / 35
Operations with sequences
• As you know them from primary school, just do it for all times.
• Addition
• Subtraction
• Multiplication
• Mind the “masking effect” of zeros
• When plotting in Python, use stem rather than plot to show that we have
discrete values.
• But remember this is a lecture example, in normal life, we’ll be happily using
plot also with discrete signals
#basicops_seq 5 / 35
Linear function
• Parameter a – slope (směrnice, sklon)
• Parameter b – offset, bias (posun).
#linear
6 / 35
Derivations and integrals
• Example on a simple quadratic function:
#deriv_int_anal
7 / 35
Derivation done numerically
• Analytical form of derivation might not exist, or we are given an input
signal, or just too lazy …
• Make use of the definition of derivation
• and just estimate the derivative from 2 points close to each other …
#deriv_num
8 / 35
Finite integral from t1 to t2
• Analytically using the primitive function:
9 / 35
#int_anal_num
Cosine function (cosínusovka) – continuous
time
• Basic cosine
• has
• Period (perioda) 2π rad – we are measuring angles in radians.
• Magnitude (amplituda) 1
• Phase shift (fázové posunutí, fáze) 0
#cosine_basic
10 / 35
Cosine with more interesting parameters
• Setting the number of periods per second: frequency (frekvence,
kmitočet) f1 in Hertz.
• The period (in seconds) then becomes
#cosine_full
12 / 35
Cosine sequence – discrete time
• Sequence
• Not very interesting - something like 6.28 samples per period ???
• Enforcing the number of samples in one period to be N:
14 / 35
Complex unit
• Is defined as
• Has “circular property”
15 / 35
Complex number as a vector and its two
forms
• It is convenient to imagine complex numbers as vectors starting in
0+0j and going to the given complex number.
• Component form (složkový tvar) of a complex number
• a is real component
• b is imaginary component
• Polar form (polární nebo goniometrický tvar)
• r is magnitude or absolute value (modul, absolutní
hodnota, magnituda)
• φ is phase (fáze, úhel, argument)
16 / 35
Conversion of forms using basic geometry
• From polar to component
… so the component form can be written as
• From component to polar
• Be careful about the inverse tangens and always check that you have got the
result correctly.
• See the 1st numercical exercise.
• Python (and all other languages supporting math) have appropriate
functions
• np.abs(), np.angle()
17 / 35
Exponential form of complex number
• or (if lazy to type in LaTeX)
or (el. engineers)
18 / 35
Operations with complex numbers
• Addition and subtraction in composite form
• Easy to imagine as vectors in the complex plane !
19 / 35
Operations with complex numbers II
• Multiplication
• Possible in component form, but too complicated …
• Much more convenient in the exponential form: multiply the magnitudes and
sum the phases !
• Division: similar
20 / 35
Operations with complex numbers III
• Complex conjugation (komplexní sdružení)
• Component form: imaginary part swapped
• Exponential form: phase swapped
• Sum of complex-conjugated complex numbers is a real number
22 / 35
Complex exponential
• For zero phase:
• The point then starts moving counter-clock-wise
(proti směru hodinových ručiček)
• Much better to see it on a physical model
the „complex bottle“
#complex_exp_minus
24 / 35
Operations with complex exponential II
Changing the magnitude – just multiply with a constant
#complex_exp_magnitude
Changing the phase – just multiply with a complex number laying on
the unit circle with the desired phase
• the complex exponential will acquire the desired phase
#complex_exp_phase
Changing both – multiply with a complex number of which the
magnitude will be the desired magnitude change, and phase will be the
desired phase change
#complex_exp_magnitude_phase
25 / 35
Complex exponential with period different
from 2π
• Exactly the same as for the cosine: multiply time by angular
frequency so that
• the angular frequency can be even negative, in this case, the complex
exponential will “turn” in the opposite direction
#complex_exponential_ang_freq
26 / 35
Complex exponential – the whole thing
• the complex coefficient c1
• Its magnitude determines the magnitude of resulting complex exponential.
• Its phase determines the phase of resulting complex exponential.
27 / 35
Breaking a cosine into two complex
exponentials
• Using the well known formula
• The cosine without initial phase can be decomposed as
29 / 35
General complex exponential with discrete
time
• Similarly as for the continuous-time one,
• magnitude of c determines the magnitude of resulting complex exponential.
• phase of c determines the phase of resulting complex exponential.
• k determines the number of periods (“turns”) in N samples
#complex_exp_discrete_general
30 / 35
Decomposing a discrete cosine into two
complex exponentials
• Again using the well known formula
#discrete_cos_decomposition
31 / 35
Physical model for discrete complex
exponential
• Use whatever long object and put something into it …
32 / 35
Sum of discrete complex exponential over
one period
• Examples for N = 2, 4, 8, and 16.
• Obvious that the blue parts will cancel out with the red ones => zero
• It generalizes also for other N’s. In case more math needed, here it is !
33 / 35
Sum of a continuous complex exponential
over one period
• Red and blue parts cancel out
(integral is nothing but a sum …)
34 / 35
Summary
• ISS is actually an applied math course (sometimes also dubbed “Fourier hell” …)
• Cosines, sines and complex exponentials are the very basis of spectral analysis.
• It is good to write equations but writing 2 lines of Python code, and visualizing
the result, helps understanding the math!
• Funny TODO: Impress your friends in a pub by creating a physical model of a
complex exponential (and send me photos).
• Serious TODO: think about the relations of regular and normalized frequencies
when one samples a continuous signal with sampling frequency F s.
• Consider both standard and angular ones.
• What are their units ?
• How to convert one to another ?
35 / 35