info 150: a mathematical foundation for...

21
INFO 150: A Mathematical Foundation for Informatics Peter J. Haas Lecture 1 1/ 20

Upload: others

Post on 20-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

INFO 150: A Mathematical Foundation

for Informatics

Peter J. Haas

Lecture 1 1/ 20

Page 2: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Course Overview and LogisticsBrief overviewCourse LogisticsIntroductions

Number Puzzles and SequencesNumber puzzlesSequences and Sequence NotationDiscovering Patterns in SequencesSums

Lecture 1 2/ 20

Page 3: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

INFO 150: A Mathematical Foundation for Informatics

Details at the course website: tinyurl.com/INFO150-F19

Teaching Sta↵

I Instructor: Prof. Peter J. Haas

I TA: Shivam Srivastava

I UCA: Lucy Cousins

I Grader: David Ter-Ovanesyan

What is this introductory course about?

I Discrete mathematics and the mathematical methodI Versus continuous mathematics (calculus)I Because computers deal with 0’s and 1’s

Aimed at students in Informatics

I The “outward looking” area of computer science

I Focus on development & application of computational principles and techniquesto advance other disciplines

I Prerequisites: A high school math background (algebra! ya ⇥ yb = ya+b)

Lecture 1 3/ 20

Page 4: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Course Goals and Objectives

Goals

I Learn to think (more) mathematically

I Learn to communicate thinking using mathematical language

I Prep for future courses in computer science

Objectives (see website)

I Recursive thinking: dealing wth complexity

I Mathematical logic: thinking clearly

I Mathematical writing: communicating clearly

I Abstraction: Leveraging what you know

I Functions, relations, sets: basis for programs and data

I Combinatorics: counting things

I Probability: dealing with uncertainty

I Graphs: dealing with relationships

Applications to puzzles, games, programming, and important real-world problems

Lecture 1 4/ 20

HS Friends

College Friends

Girlfriend's Friends

University FriendsOther AcademicFriends

griffsgraphs.wordpress.com/2012/07/02/a-facebook-network/

Page 5: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Course logistics

Textbook: Ensley and Crawley

I Expensive, but can buy used or rent (e.g., eCampus)

I Do not buy Student Solutions Manual in place of textbook

Schedules

I Class meetings MW 2:30-3:45 in CompSci 140I Attendance is required!I In class graded activities (bring paper and pencil!)I Lecture topics and readings: see syllabus on website

I My o�ce hours: Mon 4:30-5:30, Wed 10-11, and by appointment

I Shivam’s o�ce hours: Tues 10:30-noon, Fri 10:30-noon

I Two evening midterms (7-9pm):I Thurs 17 Oct in ILC S331I Thurs 14 Nov (location TBD)

I Final exam: Fri 13 Dec, 3:30-5:30 (location TBD)

Lecture slides

I Annotated corrected slides posted after each unit

Lecture 1 5/ 20

Page 6: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

More Logistics

Piazza for online discussion

I Sign up via webpage link

I Announcements will emailed from Piazza & posted on website

I Ground rulesI Be respectful, on-topic, and helpful (anonymity allowed—don’t abuse!)I Hints or clarifications only (don’t just ask for or post answers)I For private matters, post privately (preferred) or email me.

Academic honesty policy

I See link to UMass policy page on website—ignorance is no excuse! (AIQ quiz)

I Exams: closed book, no outside help (cheating = F)

I In-class assignments: help from classmates & instructor(writeup must be in own words)

I Homework (we will use Gradescope)I Can discuss with other studentsI Writeup in your own words: appearance of copying = FI External sources (print or web) must be citedI No posting of class materials (incl. video/audio recordings) online without

prior instructor permission, or providing to third party such as StudySoup

Lecture 1 6/ 20

- sign up now !

Takenrite

then

Page 7: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Course Requirements and Grading

I Homework/attendance: 40%

I Two midterm exams: 30%

I Final exam: 30%I Optional Project:

I Research report on a topic in discrete mathI 3-5 pages of text exclusive of picturesI Report due by end of semesterI Will push grade up if on boundary

I More pushing if lower current gradeI If doing well, won’t hurt not to do the project

I Let us know if you are falling behind (Academic Alert...)

Lecture 1 7/ 20

Page 8: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Introductions

Me

I Joined UMass in 2017 after 30 years at IBM Research &Stanford University

I Math/CS interests: Data management & analytics,prob/stats, computer simulation

I Real-world applications: air pollution modeling, computationalbiology (Watson and P53), healthcare

I Random fact: related by marriage to the screenwriter for StarWars

You?

Lecture 1 8/ 20

Page 9: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Mathematics as a Language

A language has two parts:

I Syntax and Grammar: How do we talk about things?I Math notation (a = a1, a2, . . .; S =

Pki=1 i

2; Y = X>X, etc.)

I Logic (8x 2 N, 9y 2 N such that y = x/2)

I Mathematical objects: What things do we talk about?I Numbers (sequences, numerical patterns, series, divisibility, . . .)I SetsI FunctionsI ProbabilitiesI GraphsI Matrices

We use mathematical language to talk about the real world

via abstraction

I 35 = approximate number of people in the room

I S = the set of people in the room

I Is a math “sentence” true? (proofs & counter-examples)

Lecture 1 9/ 20

Page 10: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Number Puzzles [E&C Section 1.2]

1. 1, 9, 17, 25, 33, 41, ??

2. 1, 4, 9, 16, 25, 36, ??

3. 2, 4, 8, 16, 32, 64, ??

4. 1, 2, 6, 24, 120, 720, ??

Why do we care?

I Training for recursive thinking in a simple setting

I Used later when learning how to write proofs

I Diagnosing time and space complexity of computationsI “At each time step, each process spawns two more processes”I “Each sampling step removes 2/3 of the items and adds 10 more items”I “The nth pass through the data has to process n rows of the table

Lecture 1 10/ 20

Page 11: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Guess the Next Number

1. 1, 9, 17, 25, 33, 41, ??

2. 1, 4, 9, 16, 25, 36, ??

3. 2, 4, 8, 16, 32, 64, ??

4. 1, 2, 6, 24, 120, 720, ??

Strategy: Look for Patterns

I Relate each term to previous terms (arithmetic formula)

I Describe in terms of position in sequence

I Recognize the set of integers from the examples

Lecture 1 11/ 20

Page 12: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Patterns

Example

I Describe the sequence 1, 3, 5, 7, 9, ... each of the three ways

Solution

I Relate each term to previous terms

I Describe in terms of position in sequence

I Recognize the set of integers from the examples

Lecture 1 12/ 20

Each term is 2 more than previous

nth form is 2. n - I

The odd natural numbers

Page 13: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Sequences and Sequence Notation

Recursive Formula

Each term is described in relation to previous terms via a recurrencerelation

Closed Formula

Each term is described in terms of its position in the sequence

Sequence Notation

Sequence name is a lower-case letter (a, b, . . .) and a subscript givesposition in sequence: an = nth term in sequence a

Example

I a = 1, 3, 5, 7, 9, . . .

I a1 = 1, a2 = 3, a5 = 9(it’s like a function; subscript = ordinal number)

I Closed formula: an = 2n � 1 (for n � 1)

I Recursive formula: a1 = 1 and an = an�1 + 2 (for n � 2)

Lecture 1 13/ 20

Page 14: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Examples

For the sequence an = 2n � 1 with a1 = 1:

I Write the first 3 terms:

I Value of 10th term: a10 =

I Formula for (k + 1)st term:

I Formula for bi = a2i�3:

For the sequence an = an�1 + 5 with a1 = 1:

I Write the first 3 terms:

I Recursive formula for 80th term: a80 =

I Recursive formula for (k + 1)st term:

I Recursive formula for a2j�3:

Lecture 1 14/ 20

9--1,92=22 - 1--3,95-23-1=7

210 - I = 1024 - I = 1023

Get ,= 2kt

'

- I

bi -

- an :3= Ii →

- I fbi-E-I-i.ly)

91=1,

Asea ,+5=6

,Az =

92+5=11%+5

akti-acn.ly - it 5=945

Aaj . 5- Aaj - D - It 5=9141-5

Page 15: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Discovering Patterns in Sequences

Give Recursive and closed formulas:

1. 1, 9, 17, 25, 33, 41, ??

2. 1, 4, 9, 16, 25, 36, ??

(1) look for di↵erences and quotients—how fast do the numbers grow?(2) compare to simple series with same recurrence

Lecture 1 15/ 20

tutti . ..

µg

recursive form

bn" 8,16 ,24,32

di-lahdan-an.mg

bn-

- 8h and an " bn -7,

soan=8n-C7'

49an,Ap - g= n

'- ( n - if = n

'- ( hunt 1) = Lh - I

,'

so

e1awdan=amt2hT

Page 16: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Discovering Patterns in Sequences

Give Recursive and closed formulas:

1. 2, 4, 8, 16, 32, 64, ??

2. 1, 2, 6, 24, 120, 720, ??

(1) look for di↵erences and quotients—how fast do the numbers grow?(2) compare to simple series with same recurrence

Lecture 1 16/ 20

' "

an-uzn.m.ITan - an - i = I - Ji"

I I- '

Ch - t ) i I'

,

so

ar-2and9ni9n.itI-t@pnnotethataaI_aa3jaa4-n.soF.iq

[email protected]¥ -

- 4, aang; n so 9-uiandan-nan.IT

a,

i I,

a 2 . 9=2 . I,

a 5- 3 . ai . 3 ' L ' I

An=n-Cn-D.ln.2il=#Tq"

n factorial"

Page 17: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

A Rockstar Sequence: Fibonacci Numbers

The Sequence

1, 1, 2, 3, 5, 8, 13, 21, 34, . . .

The recurrence relation

F1 = F2 = 1 and Fn = Fn�1 + Fn�2 for n � 3

The closed formula (Binet’s formula)

Fn =1p5

1 +

p5

2

!n

� 1�

p5

2

!n!

Applications include (see Fibonacci Quarterly):

1. Fibonacci search, Fibonacci heaps

2. Biology and more (leaf/petal patterns, tree branching, . . .)

Lecture 1 17/ 20

Page 18: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Sums

Notation for sums

nX

k=1

ak = a1 + a2 + · · ·+ an = sum of first n terms of sequence a

Extended notation for sums

nX

k=m

ak = am + am+1 + · · ·+ an

Example: Evaluate the sums

I3X

k=1

(2k � 1):

I2X

j=0

3j :

I3X

k=3

k2:

I3X

k=1

1

k(k + 1):

Lecture 1 18/ 20

n - Mtl terms

11-345=9 5=9

3%31+5=11-31-9--13 It f-t.fi?g--f

Page 19: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Sums: More Examples

Notation for sums

nX

k=1

ak = a1 + a2 + · · ·+ an = sum of first n terms of sequence a

Examples

I Sum of first 10 numbersin sequence ak = 1/k with k � 1

I 2 + 4 + 8 + 16 + 32 + 64

Lecture 1 19/ 20

10

E'

q= 's t 's t . . - t.to

K = I

an I 2h

E n

so E 2

n= I

Page 20: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Sums: Complexity Example

kth pass through database looks at k records

I How many records are looked at by the end of the nth pass?

S =nX

k=1

k = 1 + 2 + · · ·+ n

Obtain closed form:

Lecture 1 20/ 21

S = It 2 t . -- t µ- I ) th

sa n t Cn - Dt --

- t 2 t I

--25 = cuts ) t ( nm ) t . -

- t Intl ) tlntl ) =h( ntl )

so s=ncn-

Page 21: INFO 150: A Mathematical Foundation for Informaticsphaas/INFO150/slides/slecture1-annotated.pdfDiscovering Patterns in Sequences Sums Lecture 1 2/ 20. INFO 150: A Mathematical Foundation

Stability of Sequences

Example

Give the first 4 terms of an = 3an�1 � 6 with

I a1 = 2:

I a1 = 4:

I a1 = 3:

0 20 40 60 80 100

0

10

20

30

40

50

60

70

n

a1 = 1a1 = 30a1 = 60

an

an = 0.9 an−1 + 3

Lecture 1 20/ 20

Try it !

Q : How to

figure out thestable

startingvaluewithout

plotting?