Initial work
This commit is contained in:
6
CS1029/notes-2023-09-19
Normal file
6
CS1029/notes-2023-09-19
Normal file
@@ -0,0 +1,6 @@
|
||||
Test in late October & late November, final exams in December (20%, 20%, 80%); all multiple choice?
|
||||
Books: (reccommended)
|
||||
- Discrete Mathematics and Its Applications, 8th edition,Kenneth H. Rosen
|
||||
- Mathematics for Calculus, 6th edition. Stewart et al.
|
||||
|
||||
|
||||
4
CS1029/notes-2023-09-20
Normal file
4
CS1029/notes-2023-09-20
Normal file
@@ -0,0 +1,4 @@
|
||||
Why must we review *rounding*, how negatives multiply, assoc/commut/distrib properties - all of this is early secondary school or primary school!
|
||||
exponentiation, absolute values
|
||||
|
||||
Is this not assumed knowledge?!
|
||||
2
CS1029/notes-2023-09-26
Normal file
2
CS1029/notes-2023-09-26
Normal file
@@ -0,0 +1,2 @@
|
||||
# Propositional Logic
|
||||
|
||||
0
CS1029/notes-2023-10-03
Normal file
0
CS1029/notes-2023-10-03
Normal file
0
CS1029/notes-2023-10-10
Normal file
0
CS1029/notes-2023-10-10
Normal file
8
CS1029/notes-2023-10-11
Normal file
8
CS1029/notes-2023-10-11
Normal file
@@ -0,0 +1,8 @@
|
||||
image = range
|
||||
codomain: set that a function is stated to evaluate to; range: values that are possible from a function
|
||||
onto function: surjection
|
||||
bijective: injective & surjective
|
||||
injective: \forall x, y \in \operatorname{Domain}.~ f(x) = f(y) \implies x = y \tag{one-to-one}
|
||||
surjective: \forall y \in \operatorname{Codomain}.~\exists x \in \operatorname{Domain}.~ f(x) = y \tag{codomain = range}
|
||||
|
||||
inverse only a function for bijective functions - not surjective means undefined for some values of the domain, not injective means multi-valued for some values of the domain
|
||||
1
CS1029/notes-2023-10-17
Normal file
1
CS1029/notes-2023-10-17
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
CS1029/notes-2023-10-18
Normal file
1
CS1029/notes-2023-10-18
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
0
CS1029/notes-2023-10-24
Normal file
0
CS1029/notes-2023-10-24
Normal file
7
CS1029/notes-2023-10-25
Normal file
7
CS1029/notes-2023-10-25
Normal file
@@ -0,0 +1,7 @@
|
||||
Closure of a relation R is the smallest relation containing R and meeting a property
|
||||
EG. reflexive closure of R (on A) is R | { (a, a) | a \in A }
|
||||
symmetric closure of R is R | mirror(R)
|
||||
|
||||
Equivalent: R is reflexive, symmetric, and transitive - f(x) = f(y) for some function f
|
||||
Equivalence classes: sets of values which R considers equivalent
|
||||
disjoint, nonempty subsets of domain
|
||||
13
CS1029/notes-2023-10-31
Normal file
13
CS1029/notes-2023-10-31
Normal file
@@ -0,0 +1,13 @@
|
||||
Simple Graph: unique connections, no reflexive connections
|
||||
Multigraphs: multiple connections between two vertices permitted
|
||||
Directed graphs/digraph
|
||||
Pseudograph: permits self-links
|
||||
Degree of vertex in an undirected graph: edges connected to vertex (loops contribute twice)
|
||||
in a directed graph: in-degree is edges pointing to a vertex, out-degree is pointing out
|
||||
|
||||
Pendant vertex has degree 1
|
||||
Sum of the degree of all vertices in an undirected graphs is twice the number of edges: handshake theorem
|
||||
Bipartite: can be partitioned into two sets of vertices such that no edge connects two vertices in the same set
|
||||
Complete bipartite: two vertices are connected \iff they are in seperate partitions
|
||||
|
||||
Matching in a bipartite graph: find a subgraph such that all vertices have *exactly* 1 edge attached
|
||||
11
CS1029/practical-2023-09-29/datasci
Normal file
11
CS1029/practical-2023-09-29/datasci
Normal file
@@ -0,0 +1,11 @@
|
||||
Books: id.loc.gov
|
||||
Library of Congress linked data
|
||||
Already in relatively usable formats: XML, JSONLD, etc; further work would be dependent on type of analysis
|
||||
|
||||
Disease risk: data.gov.ie - large amounts of discharge data in Health/HSE section
|
||||
Something could be stitched together estimating risks
|
||||
|
||||
Universities: https://www.ucas.com/data-and-analysis/undergraduate-statistics-and-reports
|
||||
All CSVs in zips
|
||||
|
||||
|
||||
6
CS1029/practical-2023-09-29/numbers
Normal file
6
CS1029/practical-2023-09-29/numbers
Normal file
@@ -0,0 +1,6 @@
|
||||
06. 1 0 1/2 π
|
||||
07. commutativity (+), commutativity (*), associativity (+), associativity (*), distributivity of * over +
|
||||
08. 3x+3y 8a-8b 28y-14x 3ab+3ac-6ad
|
||||
09. 17/30 9/20 3 1/36
|
||||
11. 100 -12 6/24 2 -1 1
|
||||
13. 109.9884 48.36 30.24 42313990.36
|
||||
93
CS1029/practical-2023-10-06/prop
Normal file
93
CS1029/practical-2023-10-06/prop
Normal file
@@ -0,0 +1,93 @@
|
||||
01. TFTF----FF
|
||||
02. a) Linda is older than Sanjay (given that age is continuous)
|
||||
b) Mei does not make more money than Isabella (salaries are discrete)
|
||||
c) Moshe is shorter than Monica (height is continuous)
|
||||
d) Abby is not richer than Ricardo (is wealth continuous?)
|
||||
e) Quincy is not smarter than Venkat (unquantifiable ∴ continuous)
|
||||
f) 2 + 1 /= 3
|
||||
g) The summer in Maine is not hot and sunny
|
||||
i) Jennifer and Teja are not friends
|
||||
03. TTFF
|
||||
4 a) I did not buy a lottery ticket this week
|
||||
b) I bought a lottery ticket this week and I won the million dollar jackpot
|
||||
c) If I bought a lottery ticket this week, I won the million dollar jackpot
|
||||
d) I bought a lottery ticket this week, or I won the million dollar jackpot
|
||||
e) I bought a lottery ticket if and only if I won the million dollar jackpot
|
||||
f) If I didn't buy a lottery ticket this week, I didn't win the million dollar jackpot
|
||||
g) I didn't buy a lottery ticket this week, and I didn't win the million dollar jackpot
|
||||
h) I didn't buy a lottery ticket this week, or I did buy a lottery ticket this week and I won the million dollar jackpot
|
||||
-> If I bought a lottery ticket this week, I won the million dollar jackpot
|
||||
05. a) !p
|
||||
b) p & !q
|
||||
c) p -> q
|
||||
d) !p -> !q
|
||||
e) p -> q
|
||||
f) q & !p
|
||||
g) p <-> q
|
||||
06. a) r & !p
|
||||
b) !p & q & r
|
||||
c) r -> (!p <-> q)
|
||||
d) !q & !p & r
|
||||
e) q -> (!r & !p)
|
||||
f) (p & r) -> !q
|
||||
07. TFTF
|
||||
08. FTTT
|
||||
09. a) If one does not wash the boss's car, one is not promoted
|
||||
b) If there exist winds from the south, there will exist a spring thaw
|
||||
c) If the computer was bought less than a year ago, the warranty is good
|
||||
d) If Willy cheats, he is caught
|
||||
e) If you do not pay a subscription fee, you cannot access the website
|
||||
f) If one knows the right people, one is elected
|
||||
g) If Carol is on a boat, she gets seasick
|
||||
10. a) p !p p -> !p
|
||||
T F F
|
||||
F T T
|
||||
b) p !p p <-> !p
|
||||
T F F
|
||||
F T F
|
||||
c) p q p ^ (p | q) (== !p & q)
|
||||
T T F
|
||||
T F F
|
||||
F T T
|
||||
F F F
|
||||
d) p q (p | q) -> (p & q)
|
||||
T T T
|
||||
T F F
|
||||
F T T
|
||||
F F T
|
||||
11. OR AND XOR
|
||||
111_1111 000_0000 111_1111
|
||||
1111_1010 1010_0000 0101_1010
|
||||
10_0111_1001 00_0100_0000 10_0011_1001
|
||||
12. a) 11000
|
||||
b) 10001
|
||||
|
||||
13.
|
||||
a) p q r (p | q) ((p | q) | r) (q | r) (p | (q | r))
|
||||
T T T T T T T
|
||||
T T F T T T T
|
||||
T F T T T T T
|
||||
T F F T T F T
|
||||
F T T T T T T
|
||||
F T F T T T T
|
||||
F F T F T T T
|
||||
F F F F F F F
|
||||
b) p q r (p & q) ((p & q) & r) (q & r) (p & (q & r))
|
||||
T T T T T T T
|
||||
T T F T F F F
|
||||
T F T F F F F
|
||||
T F F F F F F
|
||||
F T T F F T F
|
||||
F T F F F F F
|
||||
F F T F F F F
|
||||
F F F F F F F
|
||||
|
||||
14. a) Jan is not rich or is not happy
|
||||
b) Carlos will not run and will not bicycle tomorrow
|
||||
c) Mei does not walk and does not take the bus to class
|
||||
d) Ibrahim is not smart or is not hard-working
|
||||
|
||||
15. (p -> q) & (p -> r)
|
||||
≣ (!p | q) & (!p | r) # Definition of ->
|
||||
≣ (!p | (q & r)) # Distribution of | over &
|
||||
≣ p -> (q & r) # Definition of ->
|
||||
46
CS1029/practical-2023-10-13/sets
Normal file
46
CS1029/practical-2023-10-13/sets
Normal file
@@ -0,0 +1,46 @@
|
||||
1. a) the students who either live within 1 mile of the school or who walk to classes
|
||||
b) the students who live within 1 mile of the school and walk to classes
|
||||
c) the students who live within 1 mile of the school and do not walk to classes
|
||||
d) the students who walk to classes and do not live within 1 mile of the school
|
||||
|
||||
2. a) { 0, 1, 2, 3, 4, 5, 6 }
|
||||
b) { 3 }
|
||||
c) { 1, 2, 4, 5 }
|
||||
d) { 0, 6 }
|
||||
|
||||
3. a) { a, b, c, d, e, f, g, h }
|
||||
b) { a, b, c, d, e }
|
||||
c) {}
|
||||
d) { f, g, h }
|
||||
|
||||
5. A \union B = { x | x in A || x in B }; commutative as OR is commutative
|
||||
A \intersect B = { a | x in A && x in B }; commutative as AND is commutative
|
||||
|
||||
6. A - B = { x | x \in A \and x \nin B }
|
||||
!B = { x | x \nin B }
|
||||
A & !B = { x | x \in A \and x \in !B } = { x | x \in A \and x \nin B }
|
||||
|
||||
(A & B) | (A & !B) = (A | A) & (B | !B) (distribution of & over |)
|
||||
= A & U
|
||||
= A
|
||||
|
||||
7. a) { 4 6 }
|
||||
b) { 0 1 2 3 4 5 6 7 8 9 10 }
|
||||
c) { 4 5 6 8 10 }
|
||||
d) { 0 2 4 5 6 7 8 9 10 }
|
||||
|
||||
9. { 2 5 }
|
||||
|
||||
11. A ^ B = { x | x in A ^ x in B } = { x | (x in A | x in B) & !(x in A & x in B) }
|
||||
= { x | x in A | x in B } - { x | x in A & x in B }
|
||||
= (A | B) - (A & B)
|
||||
|
||||
12. a) { a: 3, b: 3, c: 1, d: 4 }
|
||||
b) { a: 2, b: 2 }
|
||||
c) { a: 1, c: 1 }
|
||||
d) { b: 1, d: 4 }
|
||||
e) { a: 5, b: 5, c: 1, d: 4}
|
||||
|
||||
14. A_i = { x | x in Z, x <= i }
|
||||
a) A_1
|
||||
b) A_n
|
||||
52
CS1029/practical-2023-10-20/functions
Normal file
52
CS1029/practical-2023-10-20/functions
Normal file
@@ -0,0 +1,52 @@
|
||||
1. a) f(x) is undefined for x = 0
|
||||
b) f(x) is complex for x < 0
|
||||
c) multivalued
|
||||
|
||||
2. a) multivalued
|
||||
b) It is
|
||||
c) undefined at x = 2
|
||||
|
||||
3. a) Z >= 0, {0..9}
|
||||
b) 0.. -> 1..?
|
||||
c) All bit strings -> N
|
||||
d) All bit strings -> N
|
||||
e) (Z^+)^2 -> Z^+
|
||||
f) (Z^+)^2 -> Z^+
|
||||
|
||||
4. a) 1 b) 2 c) -1 d) 0 e) 2 f) 3 g) 0 h) 2
|
||||
5. a) 1 b) 0 c) 0 d) -1 e) 3 f) -1 g) 2 h) 1
|
||||
|
||||
8. a) 6 b) 24 c) 120 d) 3_628_800
|
||||
|
||||
10. a)y b)n c)n
|
||||
11. {a}
|
||||
|
||||
12. a) y b) n c) n d) n
|
||||
13. a) y b) n) c) y) d) n
|
||||
|
||||
14. ynyy
|
||||
|
||||
15. a) everyone has a phone number (phone numbers should already be uniquie)
|
||||
b) None (student ids should already be unique)
|
||||
c) Every student gets a unique grade
|
||||
d) no two people come from the same town
|
||||
|
||||
16. a) the set of phone numbers
|
||||
b) the set of student ids
|
||||
c) 1..100
|
||||
d) all towns
|
||||
|
||||
17. ynnn
|
||||
18. a) { 1 }
|
||||
b) { -1, 1, 5, 9, 15 }
|
||||
c) { 0, 1, 2 }
|
||||
d) { 0, 1, 2 }
|
||||
|
||||
19. f.g = x^2 + 4x + 5, g.f = x^2 + 3
|
||||
20. f + g = x^2 + x + 3
|
||||
fg = x^3 + 2x^2 + x + 2
|
||||
|
||||
21. f^-1 doesn't exist, assuming f^-1(x) = +sqrt(x)
|
||||
a) { 1 }
|
||||
b) { x | 0 < x < 1 }
|
||||
c) { x | x > 2 }
|
||||
22
CS1029/practical-2023-10-20/m.py
Normal file
22
CS1029/practical-2023-10-20/m.py
Normal file
@@ -0,0 +1,22 @@
|
||||
def floor(n):
|
||||
return n - (n % 1)
|
||||
|
||||
def ceil(n):
|
||||
return n - (n % -1)
|
||||
|
||||
|
||||
assert floor(-1) == -1
|
||||
assert floor(1) == 1
|
||||
assert floor(1.2) == 1
|
||||
assert floor(-1.2) == -2
|
||||
assert floor(0) == 0
|
||||
assert floor(0.1) == 0
|
||||
assert floor(-0.1) == -1
|
||||
assert ceil(-1) == -1
|
||||
assert ceil(1) == 1
|
||||
assert ceil(1.2) == 2
|
||||
assert ceil(-1.2) == -1
|
||||
assert ceil(0) == 0
|
||||
assert ceil(0.1) == 1
|
||||
assert ceil(-0.1) == 0
|
||||
|
||||
35
CS1029/practical-2023-10-20/sequences
Normal file
35
CS1029/practical-2023-10-20/sequences
Normal file
@@ -0,0 +1,35 @@
|
||||
1. a) 3
|
||||
b) -1
|
||||
c) 787
|
||||
d) 2639
|
||||
|
||||
2. a) 128
|
||||
b) 7
|
||||
c) 2
|
||||
d) -256
|
||||
|
||||
3. a) 1, -2, 4, -8
|
||||
b) 3, 3, 3, 3
|
||||
c) 8, 13, 23, 71
|
||||
d) 2, 0, 8, 0
|
||||
|
||||
4. a) 2, 5, 8, 11, 14, 17, 20, 23, 26, 29
|
||||
b) 0, 0, 0, 1, 1, 1, 2, 2, 2, 3
|
||||
c) 1, 1, 3, 3, 5, 5, 7, 7, 9, 9
|
||||
d) 3, 6, 12, 24, 48, 96, 192, 384, 768, 1336
|
||||
|
||||
5. a_0 = 3, a_n = a_{n - 1} + 2 (i.e. the odd integers starting at 3)
|
||||
the primes starting at three
|
||||
- one more
|
||||
|
||||
6. a) 2, 12, 72, 432, 2592
|
||||
b) 2, 4, 16, 256, 65536
|
||||
c) 1, 2, 5, 11, 26
|
||||
d) 1, 1, 6, 27, 204
|
||||
|
||||
7. a) a_n = -3a_{n-1} + 4a_{n-2} = -3(0) + 4(0) = 0 = a_n
|
||||
b) a_n = -3(1) + 4(1) = 4 - 3 = 1 = a_n
|
||||
c) a_n = -3((-4)^{n-1}) + 4((-4)^{n-2}) = -3(-4)(-4^{n-2}) + 4((-4)^{n-2}) = (-4)^{n-2}((-3)(-4) + 4) = (-4)^{n-1}(-3 - 1) = (-4)^n = a_n
|
||||
d) a_n = -3(2*(-4)^{n-1} + 3) + 4(2 * (-4)^{n-2} + 3) = -6(-4)^{n-1} - 9 - 2(-4)^{n-1} + 12 = -8(-4)^{n-1} + 3 = 2(-4)^n + 3 = a_n
|
||||
|
||||
8.
|
||||
Reference in New Issue
Block a user