En - Mathematics 5 - Linear Algebra
En - Mathematics 5 - Linear Algebra
Module 5
1
LESSON PLAN
What we do
when we do
Elimination
Topics Visualisation / Numerical Practice Exercises in
Geometry Exercises Exercises - DS Python - TD
4/5 Rotation,
reflection of
vectors and
images, Image
processing
using matrix
operations in
Python
5
Complex Numbers
Suppose 2x = 3.
Does this equation always have a solution?
x = 3/2, but only where it makes sense. (when the solution need
not be an integer)
If you want a solution for this equation, you need to step out from
the set of integers into the set of Rationals.
So,
Should something like x2 + 1 = 0 have a solution?
(x2 - 1)(x2 + 1) = 0
(x+1)(x-1)(x-i)(x+i) = 0
along with the structure which describes A polynomial of degree n has exactly
how to add, subtract etc. n complex roots (repeated roots are
counted with multiplicity).
x is called the “real” part, y the
“imaginary part”
Complex Addition and Multiplication
Where x1 ,x2 , y1, y2 ∊ ℝ
NOTE :
z1 + z2 = (a + c ) + i( b + d ) = ( c + a ) + i( d + b) = z2 + z1 : Complex addition is
commutative because real addition is commutative
= 21 + 61i + 44(-1)
= - 23 + 61i
The Argand Plane or the Complex Plane
By extending the real number system to include complex numbers,
we lost Ordering.
The Argand plane has real numbers on the x-axis and imaginary
numbers on the y axis. We can describe a complex number z = x +
iy, in 3 ways :
1) Point (x,y)
2) Vector from 0 to z whose components are x and y
3) Point (r, θ) in polar coordinates.
Here, r is the magnitude,
By Pythagoras theorem, absolute value, norm or
modulus
Unlike polar coordinates, r ⩾ 0 for complex numbers
Example
NOTE: z2 - z1 = ( a + c ) + i( b + d) - (a + ib)
= c + id
z+ = (a + ib) + (a - ib )= 2a
Also,
24
Complex Numbers in Python
● Complex numbers are input as 1j, 3j, 2 + 5j…
-9 + 0j is still considered a complex number. They form a class in Python.
● z.real and z.imag return the real and imaginary parts of a complex number z,
abs(z), its absolute value(distance from origin) and z.conjugate(), the conjugate:
Python Exercises
1) Goal: To solve equations of type ax + b = c, where a,b, and c are complex constants. Write
a procedure which inputs a,b and c and returns the value of x.
This module has a function plot() which takes in a set of complex numbers. It also takes an
integer to adjust scaling and plots the points on a graph. Create a set S of complex numbers.
Use plot(S,10) to plot the numbers in the set.
NOTE: Copy the module in Python’s folder and import it. Make sure the default program for
opening html files is set as the web browser, and not a text file.
Python Exercises
3) Use a comprehension to create a new set Snew by adding 1+2j to each point of set S. Make
a plot of Snew.
Adding a constant
to every element
Example of a comprehension: of a Set is called
“Translation”
4) Repeat (3) by adding a new complex number so that the left-most number of set S is now at
the origin.
Python Exercises
Python Exercises
5) Plot the set in which each element is half of each element of S. Plot this set. Also, plot the
set whose elements are double those of S. What do you observe?
Multiplying or dividing
by a positive real
number is called
“Scaling”. When
divided by a real
number greater than
1, the numbers move
closer to each other
and the origin.
Python Exercises
6) Create a set A = {1+1j, 2+1j, 3+1j,2+2j }. Plot it. Now plot the set formed by multiplying
each of this complex number by i, then i2, the i3 and finally i4.
When we multiply a
point (x + iy) by i, it
becomes (ix + i2y) ~
(-y, x). This has the
same effect as
Rotating the point
by 90°
counterclockwise.
Complex Numbers - Polar form and
DeMoivre’s Theorem
31
Multiplication in Polar Form
If z is real, the angle between the ray z and the real line is 0.
= r1r2 (cos θ1cos θ2-sin θ1sin θ2)+ ir1r2 (sin θ1cos θ2+
cos θ1sin θ2)
1) i and (1+i)
2) i and 3i
1) i and (1+i) :
i is (1, 𝜋/2 )
(1+i) is (√2 , 𝜋/4)
2) i and -3i
i is (1, 𝜋/2 )
-3i is (3 , 3𝜋/2)
(1+i)/√2 is (1 , 𝜋/4)
[ (1+i)/√2 ]n = (1 , n𝜋/4)
Multiplication in Polar Form
Multiplication in Polar Form
If z = x + iy = r∠𝜃
Then :
Thus,
z = x + iy = r(cos𝜃 + isin𝜃)
- eit differentiates
as expected:
= eiθ !!!!!
Euler Equation
z = (1+i)/√2
Find
2) z2 as ei2θ
3) ei𝜋
Euler Equation
z = (1+i)/√2
Find
1) r = ½ + ½ = 1
θ = 𝜋/4
What is ii ?
Euler Equation
NOTE :
1) |eiθ| = 1
2) Conjugate :
3) Multiplication :
4) Division :
DeMoivre’s Theorem
(r , θ )n is (rn , nθ)
Or, (cosθ + isinθ)n = cos nθ + i sin nθ : This also follows directly from
Euler Equation
We solved x4 - 1 = 0 (or x4 = 1 )
All the four roots of modulus 1 - they lie on the unit circle.
http://plufa10m433.wikidot.com/sixth-roots-of-unity-with-complex-multiplication-usub6
Roots of Unity
http://plufa10m433.wikidot.com/sixth-roots-of-unity-with-complex-multiplication-usub6
What about z8 = 1?
Can you draw the roots in a diagram and guess what they are?
z8 = 1.
Roots of Unity
NOTE :
Consider xn = 1 = cos 2k𝜋 + i sin 2k𝜋 , where k is an integer
1) Roots can also
1, 𝜔, 𝜔2 ,
Taking nth root on both sides, be written as
𝜔3,.... 𝜔n-1
where 𝜔 =
cos(2k𝜋/n + i
sin 2k𝜋/n)
If |z| < 1, then as you increase the power, the mod value decreases.
Example, z = 0.5 + i0, then the set is {1, 0.5, 0.25,0.125, 0.0625...}
z0 = w, w ∊ ℂ
Take the complex plane, put a black dot for those values of w for which this series converges
to a fixed value. Then you get this image :
Supplement : - The Mandelbrot set
Supplement : - The Mandelbrot set
Looking closer :
Fractal
structure
Supplement : - The Mandelbrot set
We find a lot of fractals in nature :
Supplement : - The Mandelbrot set
Scroll through this for more pictures :
https://www.math.univ-toulouse.fr/~cheritat/wiki-draw/index.php/Mandelbrot_set
Functions of a complex number
A complex function takes a complex input and gives a complex output, often it may take a
real input and gives complex output (Example - roots of a polynomial function with real
coefficients)
Unlike real functions, which we can visualize in a single XY plane, we need two separate
Argand diagrams to visualize a complex function.
Functions of a complex number
To visualize a complex function, we will think of them as mappings :
w = f(z) takes a point in the complex z-plane and maps (sends) it to a point in the complex
w-plane.
Example: z ⟼ iz
- Under this map, A ray at angle θ is mapped to the ray at angle 2θ.
Functions of a complex number
Example: f(z) = z2
Here the real part x and imaginary part y map to real part of the function, u = (x2 - y2)
The real part x and imaginary part y map imaginary part y map to imaginary part of the
function, v = (2xy)
Suppose you have a function f with domain and range in ℂ, that is, f: ℂ ⇾ ℂ. Let a ∈ ℂ.
Where L is a complex number. This means that, given ε > 0, ∃δ > 0, such that 0 < |z-a| < δ,
then |f(z) - L| < ε.
L = L1 + iL2
a = a1 + ia2
Then,
Real part of f(z) approaches real part of L and imaginary part of f(z) approaches imaginary
part of L.
This is the same as a system with two real limits. All limit theorems hold.
Derivatives of a complex valued function of a complex
variable
Note that this value should be same for all directions in which z can approach z 0
Derivatives of a complex valued function of a complex
variable
As long as z1 is near z0, wherever z1 might be, its image w1 is such that the value of Δw/Δz =
f′(z0) is a constant, IF THE FUNCTION IS DIFFERENTIABLE;
WHY?
Cauchy - Riemann Conditions
Since the limit should be the same for all directions which z takes to approach z 0, we can
choose two directions :
Since both are equal, we can equate real parts and imaginary parts to get the Cauchy -
Riemann conditions
Differentiation - Example 1
f(z) = z2 = (x+iy)2 = (x2 - y2) +i (2xy)
Is it differentiable ?
Since the process is the same as for the real variable, you can use all the formula as long as
the Cauchy-Riemann conditions are satisfied.
Differentiation - Example 2
f(z) = 1/z = 1 / x+iy = x -i y / x2 + y2
u = x / x 2 + y2 ; v = - y / x 2 + y2
Is it differentiable ?
u=x ;v=-y
Is it differentiable ?
77
What is Linear?
We add vectors to get v + w. We multiply them by numbers to get cv and dw. Combining these two
operations gives cv + dw : the linear combination of v and w.
Sometimes we want a particular combination, from a specific choice of c and d to give one line cv +
dw.
Otherwise, we need all possible combinations cv + dw, from all all c and d : This usually fills a two
dimensional ❖
space.
Straight lines and ❖ Hyperplanes, in higher ❖ 0x + 0y, 1x + 0y,
planes dimensions 0x + 1y
.
Why Linear?
Examples:
NOTE: A linear combination does not contain
higher order terms like x2 , y2 or xy
❖ Calculations are easier.
If a system is linear, a linear combination of its
❖ Finding Inverses is easier. inputs gives the same combination of its
outputs!
❖ Any process can be approximated as a Linear process - Linearity can model our world well
enough.
Where? : Weather Prediction
Weather prediction involves solving 1000s of partial
differential equations.
The earth’s surface is split into grids and in each grid, the
second order Differential equations are approximated by
100s of linear equations.
Search Engines use Linear Algebra to rank pages for showing search results.
Google uses an algorithm called PageRank.
82
Linear System Solutions
Equation 1: x - y = 5
Equation 2: 3x - 2y = 10 .
Matrix equation :
The new line y = -5 also passes through the same point (0,-5)
x-y=5
y = -5
1) The linear combination of the two equations always gives a line which passes through
the same point(s) of intersection.
2) Our goal is to find a line parallel to x-axis (or y axis) and then use it to solve the system.
This makes the linear system look “Triangular”
3) Whatever happens to the Coefficient matrix also happens to the Column Vector
Linear System Solutions - 2 equations in two unknowns
Solve these systems and plot all the lines in your solution :
3x + 2y = 2 x + 3y = 1 2x - y = 4
x+y=2 3x + 9y = 2 -10x + 5y = -20
1) They may meet at a single point and the equations have a unique solution: The coefficient
matrix is “Invertible”
2) They are parallel and the equations have no solution : Two rows of coefficient matrix are
multiples of each other but the rows of column vector are not :
3) They are coincidental and the equations have infinite solutions (all the points on the common
line) : Two rows of coefficient matrix and column vector are related in the same way:
Linear System Solutions - 3 equations in three unknowns
Consider :
2x +4y - 2z = 2
4x + 9y - 3z = 8
-2x -3y + 7z = 10
Any two of the planes intersect in a line - shown in orange in the figure.
The third plane intersects the orange line at one point (-1, 2, 2)
Linear System Solutions - 3 equations in three unknowns
Goal : Cancel ‘x’ from the second and third equations to get
a new system with the same solution:
2x +4y - 2z = 2
y+ z =
4
y + 5z =
12
1) They may meet at a single point and their equations have a unique solution : The coefficient
matrix is “Invertible”
2) At least two of them are parallel and the equations have no solution: At least two rows of
coefficient matrix are a multiple of each other but the corresponding rows of column vector are
not
3) At least two of them are coincidental and the equations have infinite solutions (all the points on
a line or the plane itself): : Two or three rows of coefficient matrix and column vector are
related in the same way
Linear System Solutions
Goal : Given a system of Linear equations, we obtain an equivalent system which is
triangular.
Observation :
1. Multiplying a row by a constant does not change the solution of the system.
2. Multiplying and adding (or subtracting) one equation to another does not change the
solution either = Replacing one or more equation with the linear combination of the
two(or more) equations does not alter the solution.
3. Row exchanges (Equation 1 becomes equation 3 and vice versa) do not change the
solution of the system.
Questions:
1) What happens when there are more equations than the number of variables?
2) What happens when there are more variables than the number of equations?
Linear System Solutions - Using Matrices
Ax is the dot product of A and x : Each row is the dot product of a row of A with x.
Linear System Solutions - Using Matrices
Ax is also the linear combination of its columns :
In both cases,
Number of Columns of A = Number of rows of x
Linear System Solutions - Combination of columns
This is the system of equations we started with:
Equation 1: x - y = 5
Equation 2: 3x - 2y = 10
You can ask, what combination of the vectors will give the solution (5,10) :
The solution (x,y) is still the same (0,-5) that we found as the intersection point of the two
lines.
The solution is more clear in this case as we immediately see the column vector as the
second column multiplied by -5.
The number at ith row and jth column of a matrix A is aij = A[i,j], where 1 ≤ i ≤ m and 1 ≤ j ≤ n . This
number can be real, complex or taken from any other Field.
A system of Linear equations can have an unique solution when the number of equations = number
of unknown variables.In this case, m = n and the coefficient matrix is a “Square Matrix”.
A square matrix has number of rows = number of columns and n is the “order” of the matrix.
A n-vector is a n x 1 matrix.
A Quick Introduction to Matrices
Zero Matrix : aij = 0 ∀ 1 ≤ i ≤ m , 1 ≤ j ≤ n Diagonal Matrix : aij ≠ 0, if i = j & aij = 0 if i ≠ j
∀ 1 ≤ i, j ≤ n
The columns of the n × n identity matrix are unit vectors of size n. I = [ e1 e2 · · · en ] , where ek is the
kth unit vector of size n.
Triangular Matrix : A square n × n matrix A is upper triangular if Aij = 0 for i > j, and lower triangular
if Aij = 0 for i < j. (A diagonal matrix is one that is both lower and upper triangular.) If a matrix is
either lower or upper triangular, it is called triangular.
While solving a linear system of equation, we reduce the coefficient matrix A to an upper triangular
matrix.
A Quick Introduction to Matrices
How to multiply two matrices A and B?
We saw that
100
Linear System Solutions - Using Matrices (Part 1)
1) Observe the columns of coefficient matrix and the column vector to find the solution
of :
x + 3y + 2z = -3
2x + 2y + 2z = -2
3x + 5y + 4z = -5.
Remember :
2) Write the 3rd equation as a linear combination of the 1st two. Find any 3 solutions of
the system :
x+y+z=2
x + 2y + z = 3
2x + 3y + 2z = 5
Linear System Solutions - Using Matrices (Part 1)
3) Find Ix when
Find E23 x if .
Can you find the matrix that exchanges rows 1 and 3? (E13)
Let
Here, the values along the diagonal, 1 and 1 are called “pivots”. A Linear
system has a unique solution as long as any of the pivots are not zero.
Linear System Solutions - Using Matrices (Part 1)
x - 2y = 1
3x - 6y = 11.
Is EA = AE ?
7) Find AB if
Solutions of Linear Systems - Part 2
&
Matrix Operations
106
Linear System Solutions - Using Matrices (Part 2)
To further simplify, we can put all the data in one augmented matrix [ A | b ] :
The Augmented Matrix is a type of Block Matrices: Matrices that are shown as a collection of sub
matrices of appropriate sizes. Matrix operations are then performed on these submatrices.
Where B,C,D and E are matrices. This is particularly useful when the blocks
are O and I.
If the jth column of a matrix A is given by Aj then A = [A1 A2 A3 …… An ]. Every matrix is also a
block matrix containing the row vectors Bi = [ ai1 ai2 ai3 …….. ain ]
Linear System Solutions - Using Matrices (Part 2)
We reduce the matrix into a simple upper triangular form using Row exchanges and Row
elimination operations. Once the triangular form is reached, solution can be found by back
substitution.
The resulting matrix can look a little bit different in case of no solution, infinite solutions and
when there are less equations than variables.
Examples of Matrices other than in Linear Systems
Matrix Examples:
● Images as Matrices : A black and white image with M × N pixels is naturally represented as an
M × N matrix. The row index i gives the vertical position of the pixel, the column index j gives
the horizontal position of the pixel, and the i, j entry gives the pixel value
Addition(Subtraction): Two matrices of the same size can be added together. A + B = B + A = ( aij
+ bij )mxn
Commutativity: A + B = B + A and AB ≠ BA
Associativity: (A + B) + C = A + (B + C) = A + B + C and A(BC) = (AB)C =
ABC
Addition with zero matrix : A+0=0+A=A
For scalars β, γ : (β + γ)A = βA + γA and (βγ)A = β(γA)
NOTE: + here stands for scalar addition in the left hand side and addition of the matrices on the
right. For the second equation, we have scalar-scalar multiplication and then scalar-matrix
multiplication. Scalar-matrix multiplication has higher precedence than matrix addition.
A-1, if exists, is the matrix such that A-1A = AA-1 = I. Thus we can have A-2, A-3 etc
NOTE: Matrices with different rows and columns may have left inverse and right inverse but they will
not be the same.
Multiplying by A-1, A-1(Ax) = A-1b ; By Associativity, A-1(Ax) = (A-1A)x = A-1b ⇔ x = A-1b; A unique x
is possible, if inverse exists.
A Matrix A is invertible if there exists a matrix A-1, such that A-1A = AA-1 = I. For an invertible A, A-1
is unique.
Matrix Operations - Matrix Inverses
2) If there exists a non- zero vector x such that Ax = 0, then A cannot have an inverse.
Inverse of a product :
Prove!!
Idea : Solve AA-1 = I instead of Ax = b. Here, we have three columns of A-1 instead of one column of
x.
Example :
The idea is to continue till it is of the form [I | A-1] since A-1[A | I] = [I | A-1]
117
Linear System Solutions & Matrix Operations
2x + 3y - z = 4
4x + 5y + z = 0
x - 2y + 2z = - 2
Linear System Solutions - Using Matrices (Part 2)
2) The parabola y = a + bx + cx2 passes through (1, 4), (2,8) and (3,14). Find & and solve a matrix
equation for the unknowns a, b and c.
3) Choose a, b, c and d in this augmented matrix so that there is a) no solution b) infinitely many
solutions.
(A+B)(A+B) = A2 + _____________________ + B2
Linear System Solutions - Using Matrices (Part 2)
5) Three of the matrices are invertible and three are singular (No inverse). Find inverse when it exists. Give
reasons for non-invertibility (zero determinant, too few pivots, non zero solution to Ax = 0)
TP - Python Exercises for matrices
121