0% found this document useful (0 votes)
8 views84 pages

2-3+4+6-handout

This document outlines the concepts of functions, sequences, summations, and matrices, focusing on their definitions, properties, and representations. It covers various types of functions including injections, surjections, bijections, and inverse functions, along with examples to illustrate these concepts. Additionally, it introduces the composition of functions and provides a structured plan for the topics discussed in Part II of the chapter.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views84 pages

2-3+4+6-handout

This document outlines the concepts of functions, sequences, summations, and matrices, focusing on their definitions, properties, and representations. It covers various types of functions including injections, surjections, bijections, and inverse functions, along with examples to illustrate these concepts. Additionally, it introduces the composition of functions and provides a structured plan for the topics discussed in Part II of the chapter.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

Basic Structures: Sets, Functions, Sequences,

Sums, and Matrices


Chapter 2: Part II

© Marc Moreno-Maza 2020

UWO – October 20, 2020


Basic Structures: Sets, Functions, Sequences,
Sums, and Matrices
Chapter 2: Part II

© Marc Moreno-Maza 2020

UWO – October 20, 2020


Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Functions

Definition: Let A and B be two nonempty sets.


1 A function f from A to B, denoted f ∶ A → B is an
assignment of each element of A to exactly one element of B.
2 We write f (a) = b if b is the unique element of B assigned by
the function f to the element a of A.
▸ Functions are
sometimes called
mappings or
transformations.
Functions

1 A function f ∶ A → B can also be defined as a subset of A × B,


that is, a relation of A × B.
2 This subset is restricted to be a relation, where no two
elements of the relation have the same first element.
3 To be precise, a function f from A to Bcontains one, and only
one ordered pair (a, b) for every element a ∈ A.

∀x (x ∈ A → ∃y (y ∈ B ∧ (x, y ) ∈ f ))

and

∀x, y1 , y2 (((x, y1 ) ∈ f ∧ (x, y2 ) ∈ f ) → y1 = y2 )


Functions: terminology
Given a function f ∶ A → B:
1 We say f maps A to B or f is a
mapping from A to B.
2 A is called the domain of f .
3 B is called the codomain of f .
4 If f (a)=b, then b is called the
image of a under f and a is
called the preimage of b.
5 The range of f , denoted by
f (A), is the set of all images of
points in A under f . The range
is a subset of the codomain B.
6 Two functions are equal when
they have the same domain, the
same codomain and map each
element of the domain to the
same element of the codomain.
Representing functions

Functions may be specified in different ways:


1 An explicit statement of the assignment, as in the students
and grades example.
2 A formula, like in:
f (x) = x + 1.
3 A computer program.
int add(int a,int b)
{
int c;
c=a+b;
return c;
}
Questions
1 f (a) = ?
Solution: z
2 The image of d is ?
Solution: z
3 The domain of f is ?
Solution: A
4 The codomain of f is ?
Solution: B
5 The preimage of y is ?
Solution: b
6 f (A) = ?
Solution: {y , z}
7 The preimage(s) of z is/are ?
Solution: {a, c, d}
Question on functions and sets
1 If f ∶ A → B and S is a subset of A, then:

f (S) = {f (s) ∣ s ∈ S}

1 f {a, b, c} is ?
Solution: {y , z}
2 f {c, d} is ?
Solution: {z}
“many-to-one”
1 A function can map many elements in the domain on the
same element in the codomain.
2 Such a function is called a many-to-one mapping .

In this example, each of the


elements a, c, d is mapped to
z.
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Injections (i.e. one-to-one)
Definition: A function f is said to be one-to-one, or injective, if
and only if f (a) = f (b) implies that a = b for all a and b in the
domain of f . A function is said to be an injection if it is
one-to-one.
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Surjections (i.e. onto)
Definition: A function f from A to B is called onto or surjective,
if and only if for every element b ∈ B there is an element a ∈ A with
f (a) = b. A function f is called a surjection if it is onto.

1 As illustrated by the
example on the right, a
function can be surjective
(onto) but not injective
(one-to-one).
2 Vice versa, the example on
the previous slide shows
that a function can be
injective (one-to-one) but
not surjective (onto).
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Bijections
Definition: A function f is a one-to-one correspondence , or a
bijection, if it is both one-to-one and onto (injective and
surjective).
Showing that f is one-to-one or onto

Let A, B be two sets and f ∶ A → B be a function from A to B


1 Showing that f is injective means proving that for all arbitrary
x, y ∈ A we have:
f (x) = f (y ) → x = y .
2 Showing that f is not injective means proving that there exist
x, y ∈ A so that:
f (x) = f (y ) and x ≠ y .
3 Showing that f is surjective means proving that:
∀y ∈ B ∃x ∈ A f (x) = y .
4 Showing that f is not surjective means proving that:
∃y ∈ B ∀x ∈ A f (x) ≠ y .
Showing that f is one-to-one or onto

1 Example 1 : Let f be the function from {a,b,c,d} to {1,2,3}


defined by f (a) = 3, f (b) = 2, f (c) = 1, and f (d) = 3. Is f an
onto function?
Solution: Yes, f is onto since all three elements of the
codomain are images of elements in the domain. If the
codomain were changed to {1,2,3,4}, f would not be onto.
2 Example 2 : Consider function f ∶ Z → Z defined for any
x ∈ Z by equation f (x) = x 2 . Is this function onto Z
(surjective)?
Solution: No, f is not onto because there is no integer x with
x 2 = −1, for example.
Showing that f is one-to-one or onto

1 Example 3 : Consider the function f ∶ Z → Z+ defined by


equation f (x) = x 2 . Is this function onto?
Solution: No. There is no integer such that x 2 = 2, for
example
2 Example 4 : Consider function/mapping f ∶ R → R+ defined
by equation f (x) = x 2 . Is this function a onto?
Solution: Yes.
3 Is that same function f a bijection?
Solution: No. It is onto but not one-to-one.
Showing that f is one-to-one or onto

1 Example 5 : Consider the function f ∶ R+ → R+ defined by


equation f (x) = x 2 . Is this function a bijection?
Solution: Yes, Why?
2 The properties like being an injection, a surjection and a
bijection depend on the function’s domain and codomain.
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Inverse functions
1 Definition: Let f be a bijection from A to B. Then the
inverse of f , denoted f −1 , is the function from B to A defined
as f −1 (y ) = x iff f (x) = y .
2 if f was not surjective, then the relation
{(y , x) ∈ B × A ∣ f (x) = y }.
would miss to map some element from B to an element of A.
3 Moreover, if f was not injective, then the same relation would
map some element from B to more than one element of A.
Inverse functions
Questions

Example 1 : Let f be the function from {a,b,c} to {1,2,3} such


that f (a)=2, f (b) =3, and f (c)=1. Is f invertible and if so what is
its inverse?

Solution: The function f is invertible because it is a one-to-one


correspondence. The inverse function f −1 is f −1 (1) = c,
f −1 (2) = a, andf −1 (3) = b.
Questions

Example 2 : Let f ∶ Z → Z be such that f (x) = x + 1. Is f


invertible, and if so, what is its inverse?

Solution: The function f is invertible because it is a one-to-one


correspondence. The inverse function f −1 reverses the
correspondence so f −1 (y ) = y − 1.
Questions
Example 3 : Let f ∶ R → R be such that f (x) = x 2 . Is f invertible,
and if so, what is its inverse?

Solution: The function f is not invertible.


1 It is not injective since f (2) = 4 = f (−2).
2 It is also not surjective since no x ∈ R has −1 as an image.
Questions
Example 4 : Let f ∶ R → R+ be such that f (x) = x 2 . Is f
invertible, and if so, what is its inverse?

Solution: The function f is not invertible.


1 It is surjective since for every y ∈ R+ there exists x ∈ R so that
√ √
f (x) = y , namely y and − y .
2 It is not injective since f (2) = 4 = f (−2).
Questions

Example 5 : Let f ∶ R+ → R+ be such that f (x) = x 2 . Is f


invertible, and if so, what is its inverse?

Solution: Yes and the inverse is f −1 (y ) = y.
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Composition
Definition: Let A, B, C be three sets.
1 Let f ∶ B → C and g ∶ A → B be two functions.
2 The composition of f with g, denoted f ○ g is the function
from A to C defined by
f ○ g (x) = f (g (x)).
3 One trick to remember the meaning of f ○ g is to read the
symbol ○ as origin.
Composition
Composition

Example 1 : If f (x) = x 2 and g (x) = 2x + 1, then:

f (g (x)) = (2x + 1)2


and
g (f (x)) = 2x 2 + 1
Composition questions

1 Let g be the function from the set {a,b,c} to itself such that
g (a) = b, g (b) = c, and g (c) = a.
2 Let f be the function from the set {a,b,c} to the set {1,2,3}
such that f (a)=3, f (b)=2, and f (c)= 1.
3 What is the composition of f with g ?
4 The composition f ○ g is defined by
a f ○ g (a) = f (g (a)) = f (b) = 2.
b f ○ g (b) = f (g (b)) = f (c) = 1.
c f ○ g (c) = f (g (c)) = f (a) = 3.

5 Note that the composition g ○ f is not defined, because the


range of f is not a subset of the domain of g.
Composition questions
1 Let f and g be functions from the set of integers to the set of
integers defined by f (x) = 2x + 3 and g (x) = 3x + 2.
2 What is the composition of f and g, and also the composition
of g and f ?
3 Solution:
f ○ g (x) = f (g (x))
= f (3x + 2)
= 2(3x + 2) + 3
= 6x + 7

g ○ f (x) = g (f (x))
= g (2x + 3)
= 3(2x + 3) + 2
= 6x + 11
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Graphs of functions

Let f be a function from the set A to the set B. The graph of the
function f is the set of ordered pairs {(a,b) ∣ a ∈ A and f (a) = b}.

Graph of f (n) = 2n + 1 from Z Graph of f (x) = x 2 from Z to Z


to Z
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
The floor and ceiling functions

1 The floor function, denoted ⌊x⌋, is the largest integer less


than or equal to x.
2 The ceiling function, denoted ⌈x⌉, is the smallest integer
greater than or equal to x
3 Examples:
a ⌊3.5⌋ = 3 ⌈3.5⌉ = 4
b ⌊−1.5⌋ = −2 ⌈−1.5⌉ = −1
4 The floor and ceiling functions play a very important role in
computer science, since they allow to approximate real
numbers with integer numbers.
5 For instance, in computer graphics, calculations are performed
with real numbers and plotting the results (on the screen
pixels) requires to use floor or ceiling values.
The floor and ceiling functions

Graph of (a) Floor and (b) Ceiling Functions


The floor and ceiling functions
Proving properties of functions
1 Prove that if x is a real number, then we have:
1
⌊2x⌋ = ⌊x⌋ + ⌊x + ⌋
2
1 Proof: Let x = n + , where n is an integer and 0 ≤  < 1.
2 With 2x = 2n + 2, we need to discuss whether 2 < 1 holds or
not.
3 Case 1:  < 21
a 2x = 2n + 2 and ⌊2x⌋ = 2n, since 0 ≤ 2 < 1.
b ⌊x + 12 ⌋ = n, since x + 12 = n + ( 21 + ) and 0 ≤ 12 +  < 1.
c Hence, ⌊2x⌋ = 2n and ⌊x⌋ + ⌊x + 2 ⌋ = n + n = 2n.
1

4 Case 2:  ≥ 1
2
a 2x = 2n + 2 = (2n + 1) + (2 − 1) and ⌊2x⌋ = 2n + 1, since
0 ≤ 2 − 1 < 1.
b ⌊x + 2 ⌋ = ⌊n + ( 2 + )⌋ = ⌊n + 1 + ( − 2 )⌋ = n + 1, since
1 1 1

0 ≤  − 2 < 1.
1

c Hence, ⌊2x⌋ = 2n + 1 and ⌊x⌋ + ⌊x + 2 ⌋ = n + (n + 1) = 2n + 1.


1

Q.E.D.
The factorial function

Definition: f ∶ N → Z+ , denoted by f (n) = n! is the product of


the first n positive integers when n is a non-negative integer.

f (n) = 1 ⋅ 2 ⋅ ⋅ ⋅ (n − 1) ⋅ n, f (0) = 0! = 1

Stirling’s Formula:
Examples: √ n
g (n) = 2πn( )n
f (1) = 1! = 1 e
f (2) = 2! = 1 ⋅ 2 = 2
f (6) = 6! = 1 ⋅ 2 ⋅ 3 ⋅ 4 ⋅ 5 ⋅ 6 = 720 f (n) = n! ∼ g (n)

f (20) = 2, 432, 902, 008, 176, 640, 000


f (n)
lim =1
n→∞ g (n)
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Introduction

1 Sequences are ordered lists of elements.


a 1, 2, 3, 5, 8
b 1, 3, 9, 27, 81, . . .
2 Sequences are not tuples; sequences generally have infinitely
many terms.
3 Sequences arise throughout mathematics, computer science,
and in many other disciplines, ranging from botany to music.
4 We will introduce the terminology to represent sequences and
sums of the terms in the sequences.
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Sequences

1 Definition: A sequence is a function from a subset of the


integers (usually either the set {0, 1, 2, 3, 4, . . . } or
{1, 2, 3, 4, . . . } ) to a set S, that is, f ∶ N → S or f ∶ Z+ → S
+

2 The notation an is used to denote the image of the integer n.


3 We can think of an as the equivalent of f (n) where f is a
function f ∶ N → S.
4 We call an a term of the sequence.

an = f (n)
Sequences

Example: Consider the sequence {an } where:


1
an = {an } = {a1 , a2 , a3 , . . . }, for n ∈ Z+
n
1 1 1
1, , , , . . .
2 3 4
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Geometric progressions
Definition: A geometric progression is a sequence of the form:
a, ar , ar 2 , . . . , ar n , . . . an = ar n
where the initial term a and the common ratio r are real numbers.

Examples:
1 Let a = 1 and r = −1. Then:

{bn } = {b0 , b1 , b2 , b3 , b4 , . . . } = {1, −1, 1, −1, 1, . . . }

2 Let a = 2 and r = 5. Then:


{cn } = {c0 , c1 , c2 , c3 , c4 , . . . } = {2, 10, 50, 250, 1250, . . . }

3 Let a = 6 and r = 13 . Then:


2 2 2
{dn } = {d0 , d1 , d2 , d3 , d4 , . . . } = {6, 2, , , , . . . }
3 9 27
Arithmetic progressions
Definition: A arithmetic progression is a sequence of the form:
a, a + d, a + 2d, . . . , a + nd, . . . an = a + nd
where initial term a and common difference d are real numbers.

Examples:
1 Let a = −1 and d = 4. Then:

{sn } = {s0 , s1 , s2 , s3 , s4 , . . . } = {−1, 3, 7, 11, 15, . . . }

2 Let a = 7 and d = −3. Then:


{tn } = {t0 , t1 , t2 , t3 , t4 , . . . } = {7, 4, 1, −2, −5, . . . }

3 Let a = 1 and d = 2. Then:


{un } = {u0 , u1 , u2 , u3 , u4 , . . . } = {1, 3, 5, 7, 9, . . . }
Strings

Definition: A string is a finite sequence of characters from a finite


set (usually called an alphabet).

1 Sequences of characters or bits are important in computer


science.
2 The empty string is represented by λ.
3 The string abcde has length 5.
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Recurrence relations

Definition: A recurrence relation for the sequence {an } is an


equation that expresses an in terms of one or more of the previous
terms of the sequence, namely, a0 , a1 , . . . , an−1 , for all integers n
with n ≥ n0 , where n0 is a non-negative integer.

1 A sequence is called a solution of a recurrence relation if its


terms satisfy the recurrence relation.
2 The initial conditions for a sequence specify the terms that
precede the first term where the recurrence relation takes
effect.
Questions about recurrence relations

Example 1: Let {an } be a sequence that satisfies the recurrence


relation an = an−1 + 3 for n = 1, 2, 3, 4, . . . and suppose that a0 = 2.
What are a1 , a2 and a3 ?

[Here a0 = 2 is the initial condition.]

Solution: We see from the recurrence relation that:


a1 = a0 + 3 = 2 + 3 = 5
a2 = 5 + 3 = 8
a3 = 8 + 3 = 11
Questions about recurrence relations

Example 2: Let {an } be a sequence that satisfies the recurrence


relation an = an−1 − an−2 for n = 2, 3, 4, . . . and suppose that a0 = 3
and a1 = 5. What are a2 and a3 ?

[Here the initial conditions are a0 = 3 and a1 = 5.] Solution: We


see from the recurrence relation that:
a2 = a1 − a0 = 5 − 3 = 2
a3 = a2 − a1 = 2 − 5 = −3
The Fibonacci sequence
Definition: Define the Fibonacci sequence, f0 , f1 , f2 , . . . by:
1 Initial Conditions: f0 = 0, f1 = 1
2 Recurrence Relation: fn = fn−1 + fn−2

Example: Find f2 , f3 , f4 , f5 and f6 .

Solution:
f0 = 0
f1 = 1
f2 = f1 + f0 = 1 + 0 = 1
f3 = f2 + f1 = 1 + 1 = 2
f4 = f3 + f2 = 2 + 1 = 3
f5 = f4 + f3 = 3 + 2 = 5
f6 = f5 + f4 = 5 + 3 = 8
Solving recurrence relations

1 Finding a formula for the nth term of the sequence generated


by a recurrence relation is called solving the recurrence
relation.
2 Such a formula is called a closed formula.
3 Various methods for solving recurrence relations will be
covered in Chapter 5 where recurrence relations will be
studied in greater depth.
4 Here we illustrate by example the method of iteration in which
we need to guess the formula. The guess can be proved
correct by the method of induction (Chapter 5).
Iterative solution example
Method 1 : Working upward (forward substitution)

Let {an } be a sequence that satisfies the recurrence relation


an = an−1 + 3 for n = 2, 3, 4, . . . and suppose that a1 = 2.

a1 =2
a2 =2+3
a3 = (2 + 3) + 3 =2+3⋅2
a4 = (2 + 2 ⋅ 3) + 3 =2+3⋅3
⋮ observed pattern (guess): am = 2 + 3(m − 1)
an = an−1 + 3 = (2 + 3 ⋅ (n − 2)) + 3 = 2 + 3(n − 1)
(confirmed)

(proof by induction covered in Chapter 5)


Iterative solution example

Method 2 : Working downward (backward substitution)

Let {an } be a sequence that satisfies the recurrence relation


an = an−1 + 3 for n = 2, 3, 4, . . . and suppose that a1 = 2.

an = an−1 + 3
= (an−2 + 3) + 3 = an−2 + 3 ⋅ 2
= (an−3 + 3) + 3 ⋅ 2 = an−3 + 3 ⋅ 3
⋮ pattern: an = an−m + 3 ⋅ m
a2 + 3(n − 2) = (a1 + 3) + 3(n − 2) = 2 + 3(n − 1)
Financial application

Example: Suppose that a person deposits $10,000.00 in a savings


account at a bank yielding 11% per year with interest compounded
annually. How much will be in the account after 30 years?
1 Let Pn denote the amount in the account after n years. Pn
satisfies the following recurrence relation:

Pn = Pn−1 + 0.11Pn−1 = (1.11)Pn−1

2 We know our initial condition is P0 = 10, 000.


Continued on next slide ↪
Financial application

Pn = Pn−1 + 0.11Pn−1 = (1.11)Pn−1 , with P0 = 10, 000


Solution: Forward Substitution

P1 = (1.11)P0
P2 = (1.11)P1 = (1.11)2 P0
P3 = (1.11)P2 = (1.11)3 P0
⋮ observed pattern (guess): Pm = (1.11)m P0
Pn = (1.11)Pn−1 = (1.11)(1.11)n−1 P0 = (1.11)n P0
(confirmed)
Pn = (1.11) 10, 000
n

P30 = (1.11)30 10, 000 = $228, 992.97

(proof by induction covered in Chapter 5)


Useful sequences
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Summations

1 Given a sequence {an }, given two indices m ≤ n, we are


interested in the sum of the terms am , am+1 , am+2 , . . . , an−1 , an .
2 Three possible notations:
n
∑ aj ∑nj=m aj ∑m≤j≤n aj
j=m
3 Each of them represents

am + am+1 + am+2 + ⋯ + an

4 The variable j is called the index of summation. It runs


through all the integers starting with its lower limit m and
ending with its upper limit n.
Summations

More generally for a set S:

∑ aj
j∈S

Examples:

n
1 ∑ rj = r0 + r1 + r2 + r3 + ⋯ + rn
0


2 ∑ 1i = 1 + 1
2 + 1
3 + 1
4 +⋯
1

3 if S = {2, 5, 7, 10}, then ∑ aj = a2 + a5 + a7 + a10


j∈S
Product notation

1 Product of the terms am , am+1 , am+2 , . . . , an−1 , an from the


sequence {an }
2 Three possible notation:
n
∏ aj ∏nj=m aj ∏m≤j≤n aj
j=m
3 Each of them represents

am × am+1 × am+2 × ⋯ × an
Geometric series
Sums of the terms of a geometric progression:

⎪ ar r −1−a
⎧ n+1
n ⎪ r ≠1
j
∑ ar = ⎨
⎩a(n + 1) r = 1
j=0 ⎪

Proof:
n
Let Sn = ∑ ar j
j=0
n
rSn = r ∑ ar j Multiply by r.
j=0
n
= ∑ ar j+1 Move new r into exponent.
j=0

Continued on next slide ↪


Geometric series
n
= ∑ ar j+1 From previous slide.
j=0
n+1
= ∑ ar k Shift index of summation with k = j + 1.
k=1
n
= ( ∑ ar k ) + (ar n+1 − a) Remove k = n + 1 term and add k = 0 term.
k=0
= Sn + (ar n+1 − a) Substitute S for the summation.

∴ rSn = Sn + (ar n+1 − a)


ar n+1 − a
Sn = if r ≠ 1.
r −1
n n
Sn = ∑ ar j = ∑a = a(n + 1) if r = 1.
j=0 j=0
Some useful summation formulae

1 The first is the


Geometric Series we
just proved.
2 We will prove some
of these later by
induction.
3 The last two have a
proof in the
textbook (required
calculus
knowledge).
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Matrices

1 Matrices are useful discrete structures that can be used in


many ways. For example, they are used to:
a describe certain types of functions known as linear
transformations.
b express which vertices of a graph are connected by edges (see
Chapter 10).
c represent systems of linear equations and their solutions

2 In later chapters, we will see matrices used to build models of


transportation systems and communication networks.
3 Algorithms based on matrix models will be presented in later
chapters.
4 Here we cover the aspect of matrix arithmetic that will be
needed later.
Matrix

Definition: A matrix is a rectangular array of numbers.


1 A matrix with m rows and n columns is called an m × n matrix.
2 The plural of matrix is matrices.
3 A matrix with the same number of rows as columns is called
square.
4 Two matrices are equal if they have the same number of rows
and the same number of columns and the corresponding
entries in every position are equal.
⎡1 1⎤
⎢ ⎥
⎢ ⎥
3 × 2 matrix ⎢0 2⎥
⎢ ⎥
⎢1 3⎥
⎣ ⎦
Notation

1 Let m and n be positive integers and let


⎡ a11 a12 ⋯ a1n ⎤
⎢ ⎥
⎢a ⎥
⎢ 21 a22 ⋯ a2n ⎥
A=⎢ ⎥
⎢ ⋮ ⋮ ⋱ ⋮ ⎥⎥

⎢am1 am2 ⋯ amn ⎥
⎣ ⎦
2 The i-th row of A is the 1 × n matrix [ai1 , ai2 , . . . , ain ].
⎡ a1j ⎤
⎢ ⎥
⎢a ⎥
⎢ ⎥
3 The j-th column of A is the m × 1 matrix: ⎢ 2j ⎥
⎢ ⋮ ⎥
⎢ ⎥
⎢amj ⎥
⎣ ⎦
4 The (i,j)-th element or entry of A is the element aij .
5 We can use A = [aij ] to denote the matrix with its (i,j)th
element equal to aij .
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Matrix arithmetic: addition

Definition: Let A = [aij ] and B = [bij ] be m × n matrices.


1 The sum of A and B, denoted by A + B, is the m × n matrix
that has aij + bij as its (i, j)-th element.
2 In other words, if A + B = [cij ] then cij = aij + bij .

Example:
⎡1 0 −1⎤ ⎡ 3 4 −1⎤⎥ ⎡⎢4 4 −2⎤⎥
⎢ ⎥ ⎢
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢2 2 −3⎥ + ⎢ 1 −3 0 ⎥ = ⎢3 −1 −3⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢3 4 0 ⎥ ⎢−1 1 2 ⎥⎦ ⎢⎣2 5 2 ⎥⎦
⎣ ⎦ ⎣

Note that matrices of different sizes can not be added.


Matrix multiplication
Definition: Let A be an m × k matrix and B be a k × n matrix.
1 The product of A and B, denoted by AB, is the m × n matrix
that has its (i,j)-th element equal to the sum of the products
of the corresponding elements from the i-th row of A and the
j-th column of B.
2 In other words, if AB = [cij ] then:

cij = ai1 b1j + ai2 b2j + ⋅ ⋅ ⋅ + aik bkj


Example: c21 = a21 b11 + a22 b21 + a23 b31
⎡1 0 4⎤⎥ ⎡14 4 ⎤
⎢ ⎡2 4⎤ ⎢ ⎥
⎢2 1 1⎥⎥ ⎢ ⎥ ⎢8 9⎥
⎢ ⎢ ⎥ ⎢ ⎥
⎢ ⎥ ⎢1 2⎥ = ⎢ ⎥
⎢3 1 0⎥⎥ ⎢ ⎥ ⎢ 7 13⎥
⎢ ⎢3 0⎥ ⎢ ⎥
⎢0 2 2⎥⎦ ⎣ ⎦ ⎢8 2⎥
⎣ ⎣ ⎦
4×3 3×2 4×2
The product of two matrices is undefined when the number of
columns in the first matrix is not the same as the number of
rows in the second .
Illustration of matrix multiplication

The Product of A = [aij ] and B = [bij ]:


⎡ a11 a12 ⋯ a1k ⎤⎥

⎢ ⎥ ⎡b11 b12 ⋯ b1j
⎢ a21 a22 ⋯ a2k ⎥ ⎢ ⋯ b1n ⎤⎥
⎢ ⎥ ⎢b
⎢ ⋮ ⋮ ⋮ ⎥⎥ ⎢ b22 ⋯ b2j ⋯ b2n ⎥⎥
A = ⎢⎢ B = ⎢ 21 ⎥
⎢ i1
a a i2 ⋯ aik ⎥⎥ ⎢ ⋮
⎢ ⋮ ⋱ ⋮ ⋱ ⋮ ⎥⎥
⎢ ⎥ ⎢bk1 bk2 ⋯ bkj
⎢ ⋮
⎢ ⋮ ⋮ ⎥⎥ ⎣ ⋯ bkn ⎥⎦
⎢am1 am2 ⋯ amk ⎥⎦

⎡ c11 c12 ⋯ c1n ⎤
⎢ ⎥
⎢ ⎥
⎢ c21 c22 ⋯ c2n ⎥
⎢ ⎥
⎢ ⋮ ⋮ ⋮ ⎥⎥

AB = ⎢ cij = ai1 b1j + ai2 b2j + ⋯ + aik bkj
⎢ ⋮ ⋮ cij ⋮ ⎥⎥
⎢ ⎥
⎢ ⋮ ⋮ ⋮ ⎥⎥

⎢cm1 cm2 ⋯ cmn ⎥
⎣ ⎦
Matrix multiplication is not commutative

Example:
1 1 2 1
A=[ ] B =[ ]
2 1 1 1

Does AB = BA ?

Solution:
3 2 4 3
AB = [ ] BA = [ ]
5 3 3 2

AB ≠ BA
Identity matrix and powers of matrices

Definition: The identity matrix of order n is the n × n matrix


In = [δij ], where δij = 1 if i = j and δij = 0 if i ≠ j.

⎡1 0 ⋯ 0⎤
⎢ ⎥
⎢0 1 ⋯ 0⎥ AIn = Im A = A when A is an
⎢ ⎥
In = ⎢ ⎥ m × n matrix
⎢⋮ ⋮ ⋱ ⋮⎥
⎢ ⎥
⎢0 1 ⋯ 1⎥
⎣ ⎦

Powers of square matrices can be defined. When A is an n × n


matrix, we have: A0 = In Ar = AAA ⋅ ⋅ ⋅ A (r times)
Plan for Part II
1. Functions
1.1 Definition and representation
1.2 Injections
1.3 Surjections
1.4 Bijection
1.5 Inverse Function
1.6 Composition
1.7 Graphs of Functions
1.8 Some Important Functions
2. Sequences and Summations
2.1 Sequences
2.2 Arithmetic and Geometric Progressions
2.3 Recurrence Relations
2.4 Summations
3. Matrices
3.1 Definition
3.2 Matrix Arithmetic
3.3 Transpose of a Matrix
Transpose of a matrix

Definition: Let A = [aij ] be an m × n matrix. The transpose of A,


denoted by At , is the n × m matrix obtained by interchanging the
rows and columns of A.

If At = [bij ], then bij = aji for i = 1, 2, . . . , n and j = 1, 2, . . . , m.

⎡1 4⎤
⎢ ⎥
1 2 3 ⎢ ⎥
The transpose of the matrix [ ] is the matrix ⎢2 5⎥.
4 5 6 ⎢ ⎥
⎢3 6⎥
⎣ ⎦
Transpose of a matrix

Definition: A square matrix A is called symmetric if A = At .


Thus A = [aij ] is symmetric if aij = aji for i and j with 1≤ i ≤ n and
1≤ j ≤ n.
⎡1 1 0 ⎤
⎢ ⎥
⎢ ⎥
The matrix ⎢1 0 1⎥ is square and symmetric.
⎢ ⎥
⎢0 1 0 ⎥
⎣ ⎦
(Square) symmetric matrices do not change when their rows and
columns are interchanged.

You might also like