0% found this document useful (0 votes)
28 views121 pages

En - Mathematics 5 - Linear Algebra

The document outlines a lesson plan for a mathematics module focusing on linear systems, matrices, and complex numbers, including visualizations, numerical exercises, and Python applications. It covers topics such as solving linear equations, matrix operations, and the properties of complex numbers, along with practical exercises for students. Additionally, it includes references for further reading and resources for coding related to matrix operations and complex numbers.

Uploaded by

blanche.nzeyidio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views121 pages

En - Mathematics 5 - Linear Algebra

The document outlines a lesson plan for a mathematics module focusing on linear systems, matrices, and complex numbers, including visualizations, numerical exercises, and Python applications. It covers topics such as solving linear equations, matrix operations, and the properties of complex numbers, along with practical exercises for students. Additionally, it includes references for further reading and resources for coding related to matrix operations and complex numbers.

Uploaded by

blanche.nzeyidio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 121

Mathematics

Module 5
1
LESSON PLAN

Topics Visualisation / Numerical Practice Exercises in


Geometry Exercises Exercises - Python -
Graded exam Guided
(DS) exercises (TD)

1/5 Why Linear Identify Linear


Systems? systems

2/5 linear system When equations Solve with and 5 problems


solutions have 0, 1 and without
matrices
infinite solutions
- 2D and 3D

What we do
when we do
Elimination
Topics Visualisation / Numerical Practice Exercises in
Geometry Exercises Exercises - DS Python - TD

3/5 matrices, Matrix 10 problems Matrix


reduction of Calculations (including operations in
Calculation of Python, Plotting
square matrices
current in Matrices,
circuits) Images as
matrices

4/5 Rotation,
reflection of
vectors and
images, Image
processing
using matrix
operations in
Python

5/5 complex Imagining Calculating with 10 problems? Plotting,


numbers complex complex Rotation and
numbers Scaling of
numbers
Complex
Numbers
References

1) Introduction to Linear Algebra, Gilbert Strang, Wellesley Cambridge Press

Video lectures from the Professor:


https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/video-lectur
es/

2) Introduction to Applied Linear Algebra , Stephen Boyd, Cambridge Univ Press

3) Coding the matrix, Philip N.Klein, Newtonian Press

Coding patches available in http://resources.codingthematrix.com/


Complex Numbers

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.

If you want x2 = 2 to have a solution, you need to admit all


real numbers, both rational and irrational.

-3, 1000000001.23687687689, ∛2, e , π are all real


numbers.

How would you define a real number?


Complex Numbers

The set of real numbers can be defined as ℝ = { x | x2 ≥ 0}

So,
Should something like x2 + 1 = 0 have a solution?

Systems with differential equation y″ + y = 0 result in oscillations.

This is seen just by substituting y = cos x or sin x, both of which


Are solutions to this equation.

The characteristic equation for this DE is r2 + 1 = 0 (y = erx)

If r = ± i, where i = √-1, then y = e±ix is the solution of the DE and


it should be somehow connected to cos x and sinx.
Complex Numbers

Find all four solutions of x4 - 1 = 0


Complex Numbers

Find all four solutions of x4 - 1 = 0

(x2 - 1)(x2 + 1) = 0

(x2 - 1)(x2 - (-1)) = 0

(x2 - 1)(x2 - i2) = 0

(x+1)(x-1)(x-i)(x+i) = 0

The roots are -1, +1, -i, +i


Complex Numbers
Writing i = √-1 makes sense in a lot of situation, so we will hold on to it.
In electrical
engineering and
All multiples of i of the form ki where k ∊ ℝ are called imaginary in Python, we
numbers. use ‘j’ instead of
‘i’
A complex number is the sum of a real number and an “imaginary
NOTE : The
number”, written as x + iy, where x,y ∊ ℝ.
imaginary part
of a complex
All real numbers are of the form x + i0, therefore ℝ ⊂ ℂ number is real

ℂ = {x + iy, x,y ∊ℝ, i = √-1 } Fundamental theorem of algebra

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 ∊ ℝ

1) Define “=” : x1 + iy1 = x2 + iy2 ⇔ x1 = x2 and y1 = y2

2) Define “+” : (x1 + iy1) + (x2 + iy2 ) = (x1 + x2 ) + i(y1 + y2)

3) Define “.” : r(x + iy) = rx + i ry

4) Define “.” : (x1 + iy1).(x2 + iy2 ) = (x1x2 - y1y2 ) + i(y1x2 + x1y2 )

Applying ordinary rules of arithmetic,


(x1 + iy1).(x2 + iy2 ) = x1x2 + ix1y2 + iy1x2 +
(i)2y1y2
= x1x2 + ix1y2 +
iy1x2 + (-1)y1y2
= x1x2 -y1y2 + ix1y2 + iy1x2
Complex Addition and Multiplication

NOTE :

1) Addition and multiplication are commutative :

z1 + z2 = (a + c ) + i( b + d ) = ( c + a ) + i( d + b) = z2 + z1 : Complex addition is
commutative because real addition is commutative

z1. z2 = ( ac - bd ) + i ( ad + bc )= ( ca - db ) + i ( cb + da ) = z2. z1 : Complex


multiplication is commutative real addition and multiplication are commutative

2) Distributivity : z1. (z2 + z3 ) = z1. z2 + z1. z3 and ( z1 + z2). z3 = z1. z3 + z1. z3


Exercise

What is 3 + 4i multiplied by 7 + 11i?


Exercise

(3 + 4i) . (7 + 11i) = 3x7 + 3x11i + 4ix7 + 4ix11i

= 21 + 33i + 28i + 44i2

= 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.

3 - i2 < 3 does not make any sense.

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

It does not include i and is therefore always positive


The Argand Plane

If z1 = a + ib and z2 = ( a + c ) + i( b + d) are two complex numbers,


the distance between them should be | z2 - z1 | = √(c2 + d2)

NOTE: z2 - z1 = ( a + c ) + i( b + d) - (a + ib)
= c + id

Like vectors, you can visualise this addition of arrows by a head-to-


tail rule
(or as the motion you get by following the motion (a, b) with the
motion (c, d)).

(or) for z1 =x1 + iy1 and z2 = x2 + iy2


Complex Conjugate
NOTE: Special case of (x1 + iy1).(x2 + iy2 ) = (x1x2 - y1y2 ) + i(y1x2
+ x 1 y2 )

(a + ib)(a - ib) = (a2 -b(-b)) + i(ba + a(-b))


= (a2 + b2) + i (ab - ab)
= a 2 + b2
= |z|2

The complex conjugate of z = a + ib is = = a - ib : It is the


image of z on the other side of the real axis.

Their polar coordinates are (r, θ) and (r, -θ)


Consequence :
Complex Conjugate
NOTE: Division of complex numbers is multiplication of a
number with another’s conjugate scaled.
The Complex Conjugate

Whenever z adds or multiplies with its conjugate, we get a real number :

z+ = (a + ib) + (a - ib )= 2a

Z. = (a + ib)(a - ib) = a2 - (ib)2 = a2 + b2

Also,

1/z = 1/(a + ib) = (a - ib)/(a + ib)(a - ib) = (a - ib)/ (a2 + b2)

If a2 + b2 = 1, (a + ib)-1 = a - ib : On the unit circle, 1/z =


Exercise
Exercise
Python Exercises for Complex
Numbers

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.

● +, -, *, /, ** all work with complex numbers.

● 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.

Syntax of a procedure: def <procedure name>(<input variable list>) : return <value to


be returned>

2) Goal : To plot a set of complex numbers with the help of plotting.py.

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.

z = a + bi r 𝜃 Other possible 𝜃 Note

1 1 0 2𝜋, 4𝜋, 6𝜋.. z is along x axis

If z = 3i, the angle is π / 2.

z = a + bi r 𝜃 Other possible 𝜃 Note

𝜋/2 𝜋/2 + 2𝜋,𝜋/2 +


4𝜋, 𝜋/2 + 6𝜋..
3i 3 z is along y axis
Multiplication in Polar Form
z = a + bi r 𝜃 Other possible 𝜃 Note

𝜋/4 𝜋/4 + 2𝜋,𝜋/4 +


4𝜋, 𝜋/4 + 6𝜋..
1+i √2 z is along y = x

𝜋/2 𝜋/2 + 2𝜋,𝜋/2 +


4𝜋, 𝜋/2 + 6𝜋..
3i 3 z is along y axis

𝜋= 3𝜋, 5𝜋, 7𝜋...


2(𝜋/2)
(3i)2 = -9 9 = 32 z is along -ve x axis

The angle doubles when the number is squared. This is why


the polar form is good for multiplying complex numbers.
Multiplication in Polar Form
Let us formalize this :

When z = a + ib is at a distance r (magnitude) and its angle


is θ(argument),

Re(z) = a = r cos θ, Im(z) = b = r sin θ

Thus we can write : z = a + ib = r cos θ + ir sin θ

z = cos θ + i sin θ has absolute value cos 2 θ + sin 2


θ = 1: It
lies on the unit circle.
Multiplication in Polar Form
Let z1 be (r1,θ1) and z2 be (r2,θ2)

z1z2 = ( r1 cos θ1 + ir1 sin θ1)( r2 cos θ2 + ir2 sin θ2)

= r1r2 (cos θ1cos θ2-sin θ1sin θ2)+ ir1r2 (sin θ1cos θ2+
cos θ1sin θ2)

= r1r2 cos (θ1+ θ2) + ir1r2 sin (θ1+θ2)

Thus, z1z2 is (r1r2 , θ1+ θ2 )

By induction, (r , θ )n is (rn , nθ)

Particularly, if r = 1, zn = (1, θ)n = (1, nθ)


Exercise
Use polar form to multiply :

1) i and (1+i)

2) i and 3i

3) (1+i) and (1+i)

4) (1+i)/ √2, n times


Exercise
Use polar form to multiply :

1) i and (1+i) :

i is (1, 𝜋/2 )
(1+i) is (√2 , 𝜋/4)

i (1+i) = (1 x √2 , 𝜋/2 + 𝜋/4) = (√2 , 3𝜋/4) = - 1 + i

2) i and -3i

i is (1, 𝜋/2 )
-3i is (3 , 3𝜋/2)

i (-3i) = (1 x 3 , 𝜋/2 + 3𝜋/2) = (3 , 2𝜋) = 3


Exercise
Use polar form to multiply :

3) (1+i) and (1+i)

(1+i) is (√2 , 𝜋/4)

(1+i)2 = (√22 , 2 x 𝜋/4) = (2 , 𝜋/2) = 2i

4) (1+i)/ √2, n times

(1+i)/√2 is (1 , 𝜋/4)

[ (1+i)/√2 ]n = (1 , n𝜋/4)
Multiplication in Polar Form
Multiplication in Polar Form

Use z1z2 is (r1r2 , θ1+ θ2 )

To show why the product of two negative real numbers is


positive
Euler Equation
We know that

If z = x + iy = r∠𝜃

Then :

1) r = sqrt(x2 + y2) and 𝜃 = tan-1 (y/x)


2) x = r cos𝜃 and y = rsin𝜃

Thus,

z = x + iy = r(cos𝜃 + isin𝜃)

Euler equation : For any complex number z, reiθ = r(cosθ + i sinθ)


Euler Equation
This matches with the power series!

ei𝜃 behaves like a true


exponential :

- eit differentiates
as expected:

cos θ + i sin θ = 1 + iθ - θ2/2! - i θ3/3! + θ4/4! + i θ5/ 5! - …..


- ei⋅0 = 1
= 1 + ((iθ) + (iθ) /2! + (iθ) /3! + (iθ) /4! + (iθ) / 5! --…..eiaeib = ei(a+b)
2 3 4 5

= eiθ !!!!!
Euler Equation
z = (1+i)/√2

Find

1) r and θ, thus eiθ

2) z2 as ei2θ

3) ei𝜋
Euler Equation
z = (1+i)/√2

Find

1) r = ½ + ½ = 1

θ = 𝜋/4

eiθ = 1(cos 𝜋/4 + i sin 𝜋/4) = z

2) z2 = (eiθ )2 = (ei𝜋/4)2 = e2i𝜋/4 = ei𝜋/2 = cos 𝜋/2 + i sin 𝜋/2 = 0 + 1.i = i

3) ei𝜋 = cos 𝜋 + i sin 𝜋 = -1

What is ii ?
Euler Equation
NOTE :

1) |eiθ| = 1

2) Conjugate :

3) Multiplication :

4) Division :
DeMoivre’s Theorem
(r , θ )n is (rn , nθ)

That is, (r(cosθ + isinθ))n = rn(cos nθ + i sin nθ)

Or, (cosθ + isinθ)n = cos nθ + i sin nθ : This also follows directly from
Euler Equation

Use DeMoivre’s Theorem to show that

cos 2θ = cos2θ - sin2 θ

sin 2θ = 2 cosθ sinθ


De Moivre’s Theorem
Use De Moivre’s Theorem to show that

cos 2θ = cos2θ - sin2 θ

sin 2θ = 2 cosθ sinθ

(cosθ + isinθ)2 = cos 2θ + i sin 2θ

cos2 θ + 2i cosθsinθ + (i)2sin θ = cos 2θ + i sin 2θ

Equating real parts : cos2 θ - sin2 θ = cos 2θ


Equating imaginary parts : 2 cosθ sinθ = sin 2θ
Roots of Unity

We solved x4 - 1 = 0 (or x4 = 1 )

± 1 and ± i are the four roots of 1.

All the four roots of modulus 1 - they lie on the unit circle.

Plot them in the complex plane.


Roots of Unity

± 1 and ± i are the four roots of 1.

Find roots when n = 4,5,6… in xn = 1 visualised as a gif here :

http://plufa10m433.wikidot.com/sixth-roots-of-unity-with-complex-multiplication-usub6
Roots of Unity

± 1 and ± i are the four roots of 1.

Find roots when n = 4,5,6… in xn = 1 visualised as a gif here :

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)

2) All the roots


come in
conjugate
pairs : If z is a
root, so is its
conjugate.
Inverse Euler Equation
Euler equation :

eiθ = cos θ + i sin θ

Also, e-iθ = cos (-θ) + i sin (-θ) = cos θ - i sin θ.

Thus, cos θ = (eiθ + e-iθ) / 2

sin θ = (eiθ - e-iθ) / 2i


Supplement : The “complexity” of complex numbers.
Consider the set {z0 , z1, z2,z3…….}

If we define zn = zn, then it would be {1, z, z2, z3 ….}

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...}

The numbers get smaller and ultimately become 0.

If |z| = 1, |zn| stays at 1 for all n.

If |z| > 1, |zn| keeps increasing and becomes closer to infinity.


Supplement : - The Mandelbrot set
If the set is given by

z0 = w, w ∊ ℂ

zn+1 = zn2 + w, that is {w, w2+w, (w2+w)+w,((w2+w)+w)2+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 :

Each tiny globule looks like

The big picture - it has a

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.

• A function w = f(z) is also called a mapping of z to w.


• z ⟼ w or z ⟼ f(z) : “z maps to w”.
• “w is the image of z”.
• If we have a set of points in the z-plane we will talk of the image of that set under the
mapping.

Example: z ⟼ iz

- the image of the imaginary z-axis is the real w-axis.


Functions of a complex number
Example: f(z) = z2

- Under this map, A ray at angle θ is mapped to the ray at angle 2θ.
Functions of a complex number
Example: f(z) = z2

If z = x + iy, z2 = (x+iy)2 = x2 + 2x(iy) + (iy)2 = (x2 - y2) + i(2xy)

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)

This is equivalent to a system of two real functions.


Limit of a complex valued function of a complex
variable
We simply extend the definition of the limit to the complex domain.

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| < ε.

Here |z-a| and |f(z)-L| are real.


Limit of a complex valued function of a complex
variable
If you write

f(z) = u(x,y) + iv(x,y)

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

What does this mean geometrically?

If w = f(z) = u(x,y) + i v(x,y) :

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;

This imposes very strong conditions on Δu and Δv.


Derivatives of a complex valued function of a complex
variable : Example where the derivative exists
Find the derivative of f(z) = z2
Derivatives of a complex valued function of a complex
variable : Example where the derivative does not
exist
Find the derivative of f(z) = conjugate of z

Let us try to calculate f′(0) first :

Both ∆x and ∆y should approach 0 if ∆z is to approach 0.

1 way of approach : ∆z goes to 0 along the x-axis then, ∆y = 0 while ∆x goes to 0:

Another way of approach : ∆z goes to 0 along the positive y-axis then :

The limits don’t agree!


Cauchy - Riemann Conditions

If f = u + iv is differentiable (analytic), then u x = vy and uy = - vx

Converse is also true : If ux ≠ vy or uy ≠ - vx then f = u + iv is not analytic.

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 :

CASE 1: Δy = 0 (approach parallel to real axis)

CASE 2: Δx = 0 (approach parallel to imaginary axis)

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)

u = (x2 - y2) ; v = (2xy)

Is it differentiable ?

Thus, the function is differentiable.


Differentiation - Example 1
f(z) = z2 = (x+iy)2 = (x2 - y2) +i (2xy)

u = (x2 - y2) ; v = (2xy)

What is its derivative ?

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 ?

Thus, the function is differentiable (except when z = 0)


Differentiation - Example 3
f(z) = conjugate of z = x -i y

u=x ;v=-y

Is it differentiable ?

Thus, the function is NOT differentiable.


Linearity - What, Why and Where?

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 unknowns are temperature, pressure, humidity, speed


and direction of wind.

The earth’s surface is split into grids and in each grid, the
second order Differential equations are approximated by
100s of linear equations.

Taken close enough, you can know what clothes to wear


tomorrow!
Where? : 3D Printing, Animation, Image
Processing
While 3D printing, shapes are
modeled as planes.

Characters in Pixar movies are from


wireframes. Each grid in the
wireframe is flat (planar/Linear) even
though the shape itself is often
curved.

- Which areas are more dense in


this wireframe?
- Which do not have too many
frames?

All images are matrices. Each entry is


a tuple (r , g, b) where r is the
intensity of red, g is the intensity of
green and b that of blue, of the pixel.
Where? : Linear Regression and Optimisation
Linear Algebra (Linear regression models) are also used for prediction of outcomes in a tournament
and stock values in the market. Politicians use it to gauge which policies are popular (only before
elections).

Linear Optimisation is used by all big companies to increase efficiency of their


processes .

Search Engines use Linear Algebra to rank pages for showing search results.
Google uses an algorithm called PageRank.

Linear Algebra and Fourier Analysis help in allocating frequencies in a


GSM network. They also ensure that your calls do not drop
when you are driving and speaking (Use Earphones though!)

So….Can France win the next


World Cup?
Solutions of Linear Systems - Part 1
&
Introduction to Matrices

82
Linear System Solutions

The central problem of Linear Algebra is to solve a system of Linear equations.

How does this system look like?

1) It uses a set of n variables, say {x1,x2,x3…. xn} or {x,y,z} or {𝛼,𝛽,𝛾, 𝛿, 𝜀...}


These variables help us to model a factor in a real life situation. Say, temperature,
volume or number of students in a program.

2) Each linear equation is a linear combination of the variables : ax + by +Good


cz =News!
d. ( a,b,c
and d can be be real, complex or from any other Mathematical Field )
When they get a term like
3) m number of equations define the constraints in our real life situation.
x2, data scientists either
ignore it or assume it is a
3x + 2y = 5 2x = 5 5x1,+ 2x2 + x3 = 0 completely new ‘linear’
variable x’!
x+y=1 y=5 5x1,+ 2x2 + x3 = 3
x ,+ 13x = 19
Linear System Solutions - 2 equations in two unknowns
Consider a system with two equations and two unknown:

Equation 1: x - y = 5
Equation 2: 3x - 2y = 10 .

The point common to both lines is (0, -5)


x = 0, y = -5 is called the solution of the linear equations.

Matrix equation :

Coefficient Matrix x Solution Vector = Column Vector


Linear System Solutions - 2 equations in two unknowns

Goal : Cancel ‘x’ from the second equation.

Equation 1 x 3 : 3x - 3y = 15 This is still the same as Line 1.


Equation 2 - 3 x Equation 1 gives : y = -5

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

When we have two lines in a system, one of three things happen :

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

Three planes in 3D space intersect at (-1, 2, 2)


x = -1, y = 2, z = 2 is the unique solution of the three linear equations.

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

Here, the goal was to get 0s under 2 in the 1st column.


Linear System Solutions - 3 equations in three unknowns
Goal : Cancel ‘y’ from the third equation to get :

( Notice the nice 2x +4y - 2z = 2


Triangular form ) y+ z =4
4z = 8

Back substituting, (-1 , 2, 2) is the point of intersection.

Goal : Use row operations to get an “Upper Triangular” Matrix.


Linear System Solutions - 3 equations in three unknowns

Solve using https://www.geogebra.org/m/QUbAFBa9 :

x+y+z=5 x+y+z=5 x+y+z=5


x-y =1 x-y =1 x-y =1
x + 2y + 3z = 10 2x + 2y + 2z = 15 2x + 2y + 2z = 10

When we have three planes, one of three things happen :

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

a11x1 + a12x2 + a13x3 ….. a1nxn = b1


a21x1 + a22x2 + a23x3 ….. a2nxn = b2
:
am1x1 + am2x2 + am3x3 ….. amnxn = bm

Our linear system becomes just one equation : Ax = b,

Coefficent matrix . Solution vector = Column vector

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 same goes for systems with more than 2 rows.


Linear System Solutions - Combination of columns
A Quick Introduction to Matrices

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

NOTE: 0 matrices of different dimensions are


different.

A linear system x = 5, 2y = 2, -z = 7, will give


raise to a diagonal matrix, from which the
solution can be read straight away, without
further calculation.
A Quick Introduction to Matrices
Identity Matrix, I : aij = 1, 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.

Sometimes a subscript is used to denote the size of an identity matrix, as in I4 or I2×2.

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

Here, B = x has a single column.

When B has more than one column, AB has more columns!

Number of Columns of A = Number of rows of B

The entry in row i column j of AB is (row of A).(column of B)


Exercises - Linear System of Equations Part 1 &
Introduction to Matrices

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)

What matrix E23-1 gets back x? : E23-1 (E23x) = x .


Linear System Solutions - Using Matrices (Part 1)
4) To solve x - y = 5 and 3x - 2y = 10. Write the linear system as a matrix equation.

We solved this system by doing

Let

Find l21 A and l21 b.

● Since Ax = b , (l21A) x = (l21b), if l21 has an “inverse” (equivalent of l ≠ 0)

● Row operations can be written as matrix multiplication.

● The final reduced equation is

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)

5) Find the reduced matrix equation for

x - 2y = 1

3x - 6y = 11.

What are the pivots? What is the solution?

What happens if the second equation were 3x - 6y = 3?

For cases like


2y = 4
3x - 2y = 5,
We can exchange rows to get non-zero pivots.
Linear System Solutions - Using Matrices (Part 1)

6) Find EA and AE for

Is EA = AE ?

What happens to rows of A in EA?

What happens to columns of A in 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 ] :

For solving we calculated

Whatever happens to A, happens to b. Therefore, we can write them as one matrix [ A | b ],


called the Augmented Matrix.

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)

The Augmented Matrix of is

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

● Rainfall data : An m × n matrix A gives the rainfall at m different locations on n consecutive


days, so A42 (which is a number) is the rainfall at location 4 on day 2.
Matrix Operations - Equality, Addition and Multiplication
A matrix can be used to represent different mathematical models. Therefore, the meaning of
addition and multiplication changes with the context. The mathematical calculation itself remains
the same. When does two
sets of Linear
Equality : Two matrices A and B are equal if Equations have
a) they have the same size the same
b) each entry of A is equal to the corresponding entry of B solution?
A = B if aij = bij , 1 ≤ i ≤ m and 1 ≤ j ≤ n

Addition(Subtraction): Two matrices of the same size can be added together. A + B = B + A = ( aij
+ bij )mxn

Scalar-Matrix Multiplication : cA =(c aij )mxn , c ∊ ℂ :


Matrix Operations - Equality, Addition and Multiplication

For Matrices A, B and C of the same size,

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.

Distributivity : C(A + B) = CA + CB and (A + B)C = AC + BC


Matrix Operations - Matrix Inverses

Inverse of A: It is valid to write A2, A3 etc. for a square matrix A.

A0 = I (Identity matrix of the same order )

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.

Why do we need Inverse of A?:

For a system of Linear equations, Ax = b

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

Properties of the Inverse :

1) Inverse of A exists if reducing Ax gives n non-zero pivots ⇔ Equation Ax = b has a unique


solution

2) If there exists a non- zero vector x such that Ax = 0, then A cannot have an inverse.

3) For a 2x2 matrix, inverse exists if ad - bc ≠ 0, and

ad - bc is called the determinant of A.


A matrix is invertible if its determinant is not 0.

4) A diagonal matrix has inverse if none of its diagonal elements is zero.

Question : What is Ax when


What does A-1 do to x?
Matrix Operations - Matrix Inverses

Inverse of a product :

If A and B are invertible matrices, then (AB)-1 = B-1 A-1

Prove!!

Calculating A-1 by Gauss-Jordan Elimination :

Idea : Solve AA-1 = I instead of Ax = b. Here, we have three columns of A-1 instead of one column of
x.

Example :

Augmented matrix for AA-1 = I is [A | I] =

Reducing this by row operations :


Matrix Operations - Matrix Inverses

The idea is to continue till it is of the form [I | A-1] since A-1[A | I] = [I | A-1]

Performing row operations to get 0 above pivots:

Dividing each row by its pivot :


Matrix Operations
Matrix transpose If A is an m × n matrix, its transpose, AT, is the n × m matrix given by (AT )ij = Aji -
The rows become columns and columns become rows.

(AT )T = A and (A-1)T = (AT )-1


(A + B) T = AT + BT and (AB) T
= BTAT
(βA)T = β (AT )

In a block matrix, each block is transposed.


Exercises - Solutions of Linear Systems - Part 2
&
Matrix Operations

117
Linear System Solutions & Matrix Operations

1) Solve by reducing augmented Matrix [ A | b ] :

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.

Which of the numbers a, b , c, or d have no effect on the solvability ?

4) Show that (A + B)2 ≠ A2 + 2AB + B2 when

(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

You might also like