Functions, Sequences, and Sums

Slides:



Advertisements
Similar presentations
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Advertisements

Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Functions Lecture 12 A B f( ) =. Functions function, f, from set A to set B associates an element, with an element The domain of f is A. The codomain.
CSE115/ENGR160 Discrete Mathematics 02/22/11 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 02/16/12 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 02/21/12
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
Functions Lecture 12 A B f( ) =. Functions function, f, from set A to set B associates an element, with an element The domain of f is A. The codomain.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
RMIT University; Taylor's College
Functions.
Discrete Structures Functions Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Functions Section 2.3.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Sequences and Summations
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Chapter 3 Functions Functions provide a means of expressing relationships between variables, which can be numbers or non-numerical objects.
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
ICS 253: Discrete Structures I
Functions Section 2.3.
Sequences and Summations
Fall 2002CMSC Discrete Structures1 … and now for… Sequences.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (2)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
FUNCTIONS.
MSU/CSE 260 Fall Functions Read Section 1.8.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Basic Structures: Sets, Functions, Sequences, and Sums CSC-2259 Discrete Structures Konstantin Busch - LSU1.
2. 1 Basic structures Sets Set Operations Functions Sequences & Sums
Basic Structures: Functions Muhammad Arief download dari
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
Sequences and Summations Section 2.4. Section Summary Sequences. – Examples: Geometric Progression, Arithmetic Progression Recurrence Relations – Example:
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Functions Section 2.3.
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
CSC102 - Discrete Structures Functions
Section Section Summary Definition of a Function. Domain, Codomain Image, Preimage Injection, Surjection, Bijection Inverse Function Function Composition.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Basic Structure : Sets, Functions, Sequences, and Sums Sequences and Summations.
3/16/20161 … and now for… Sequences. 3/16/20162 Sequences Sequences represent ordered lists of elements. A sequence is defined as a function from a subset.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
Discrete Mathematics Functions
ICS 253: Discrete Structures I
Functions Section 2.3.
CSE15 Discrete Mathematics 02/15/17
Functions Section 2.3.
Discrete Math (2) Haiming Chen Associate Professor, PhD
Lecture 7 Functions.
CSE15 Discrete Mathematics 02/27/17
CS100: Discrete structures
ICS 253: Discrete Structures I
CS 220: Discrete Structures and their Applications
CMSC Discrete Structures
Properties of Functions
Functions Section 2.3.
Presentation transcript:

Functions, Sequences, and Sums

2.3 Functions Introduction Function: task, subroutine, procedure, method, mapping, … E.g. Find the grades of student x. int findGrades(string name){ //go to grades array, //find the name, and find the corresponding grades … return grades; } Adams A Chou B Goodfriend C Rodriguez D Stevens F

2.3 Functions DEFINITION 1 Let A and B to be nonempty sets. A function f from A to B is an assignment of exactly one element of B to each element of A. We write f(a) = b if b is the unique element of B assigned by the function f to the element a of A. If f is a function from A to B, we write f: A → B. We can use a formula or a computer program to define a function. Example: f(x) = x + 1 described as: int increaseByOne(int x){ x = x + 1; return x; }

2.3 Functions DEFINITION 2 If f is a function from A to B, we say that A is the domain of f and B is the codomain of f. If f(a) = b, we say that b is the image of a and a is a preimage of b. The range of f is the set of all images of elements of A. Also, if f is a function from A to B, we say that f maps A to B. For each function, we specify its domain, codomain and the mapping of elements of the domain to elements in the codomain Two functions are said to be equal if they have the same domain, codomain, and the map elements of their common domain to the same elements of their common codomain A function is differ by changing its domain, codomain or the mapping of elements

2.3 Functions What are the domain, codomain, and range of the function that assigns grades to students described in the slide 2? Solution: domain: {Adams, Chou, Goodfriend, Rodriguez, Stevens} codomain: {A, B, C, D, F} range: {A, B, C, F}

Let f be the function that assigns the last two bits of a bit string of length 2 or greater to that string. For example, f(11010) = 10. Then, the domain of f is the set of all bit strings of length 2 or greater, and both the codomain and range are the set {00,01,10,11}

What is the domain and codomain of the function int floor(real float){…}? Solution: domain: the set of real numbers codomain: the set of integer numbers

2.3 Functions (f1 + f2 )(x) = f1(x) + f2 (x) DEFINITION 3 If f1 and f2 be functions from A to R. Then f1 + f2 and f1 f2 are also functions from A to R defined by (f1 + f2 )(x) = f1(x) + f2 (x) (f1 f2 ) (x) = f1(x) f2 (x) Example: Let f1 and f2 be functions from R to R such that f1(x) =x2 and f2 (x) = x – x2. What are the functions f1 + f2 and f1 f2 ? Solution: (f1 + f2 )(x) = f1(x) + f2 (x) = x2 + (x – x2) = x (f1 f2 ) (x) = f1(x) f2 (x) = x2(x – x2) = x3 – x4

2.3 Functions One-to-One and Onto Functions DEFINITION 5 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. (every element in the range is a unique image for element of A – all image have at most one arrow or none) a b(a ≠ b → f(a) ≠ f(b)) (If it’s a different element, it should map to a different value.) Example: Determine whether the function f from {a,b,c,d} to {1,2,3,4,5} with f(a) = 4, f(b) = 5, f(c) = 1 and f(d) = 3 is one-to-one. a 1 b 2 c 3 d 4 5 Solution: Yes.

2.3 Functions DEFINITION 7 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. Co-domain = range Example: 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? a 1 b 2 c 3 d Solution: Yes. Example: Is the function f(x) = x2 from the set of integers to the set of integers onto? Solution: No. There is no integer x with x2 = -1, for instance.

2.3 Functions DEFINITION 8 The function f is a one-to-one correspondence or a bijection, if it is both one- to-one and onto. a. One-to-one, b. Onto, c. One-to-one, d. neither d. Not a Not onto not one-to-one and onto function a 1 a a 1 a 1 1 b 2 b 1 b 2 b 2 a 2 c 3 c 2 c 3 c 3 b 3 4 d 3 d 4 d 4 c 4

2.4 Sequences and Summations A sequence is a discrete structure used to represent an ordered list Example: 1,2,3,5,8 1,3,9,27,81,…,30,… We use the notation {an} to denote the sequence. Example: Consider the sequence {an}, where an = 1/n. The list of the terms of this sequence, beginning with a1, namely a1, a2, a3, a4, …, starts with 1, 1/2, 1/3, 1/4, … DEFINITION 1 A sequence is a function from a subset of the set of integers (usually either the set {0,1,2,…} or the set {1,2,3,…}) to a set S. We use the notation an to denote the image of the integer n. We call an a term of the sequence.

2.4 Sequences and Summations It is analogue of the exponential function f(x) = arx DEFINITION 2 A geometric progression is a sequence of the form a, ar, ar2, …, arn, … where the initial term a and the common ratio r are real numbers. Example: The following sequence are geometric progressions. {bn} with bn = (-1)n starts with 1, -1, 1, -1, 1, … initial term: 1, common ratio: -1 {cn} with cn = 2*5n starts with 2, 10, 50, 250, 1250, … initial term: 2, common ratio: 5 {dn} with dn = 6 *(1/3)n starts with 6,2, 2/3, 2/9, 2/27, … initial term: 6, common ratio: 1/3

2.4 Sequences and Summations It is analogue of the linear function f(x) = dx+a DEFINITION 3 A arithmetic progression is a sequence of the form a, a + d, a + 2d, …, a + nd, … where the initial term a and the common difference d are real numbers. Example: The following sequence are arithmetic progressions. {sn} with sn = -1 + 4n starts with -1, 3, 7, 11,… initial term: -1, common difference: 4 {tn} with tn = 7 – 3n starts with 7, 4, 1, -2, … initial term: 7, common difference: -3

2.4 Sequences and Summations Example: Find formulae for the sequences with the following first five terms (a). 1, 1/2, 1/4, 1/8, 1/16 Solution: an = 1/2n (b). 1, 3, 5, 7, 9 Solution: an = (2n )+ 1 (c). 1, -1, 1, -1, 1 Solution: an = (-1)n

2.4 Sequences and Summations The sum of the terms from the sequence am + am+1, …, an can be expressed as , Or Where m is the lower limit, n is the upper limit, and j is the index of the summation Example: Express the sum of the first 100 terms of the sequence {an}, where an = 1/n for n = 1,2,3, …. Solution:

2.4 Sequences and Summations What is the value of ? Solution: = 1 + 4 + 9 + 16 + 25 = 55 Expressed with a for loop: int sum = 0; for (int i =1; i <=5; i++) { sum = sum +i*i; }

2.4 Sequences and Summations What is the value of the double summation ? Solution: = = = 6 + 12 + 18 + 24 = 60

Sequences and Summations Expressed with two for loops: int sum1 = 0; int sum2 = 0; for (int i =1; i <=4; i ++){ sum2 = 0; for (int j=1; j<=3; j++){ sum2 = sum2 + i *j; } sum1 = sum1 + sum2;

ANY QUESTIONS??? Refer to chapter 2 of the book for further reading