Wednesday, December 3, 2014

Week 12

I've used onto and 1-1 (surjective and injective) in linear algebra when looking at isomorphisms. We looked at a number of bijective transformations in class but didn't really analyze some examples that do not fall into that category. How about the following:

f(x) = |x| will cause both x = +1 and x = -1 to yield f(x) = 1 so it won't be 1-1. Secondly, nothing yields -1 so it's not onto either.
f(x) = sqrt(x) is the opposite of the previous example. Instead of taking 2 numbers and giving the same number, it spits out 2 different numbers from the input of only 1. Say x = 1, then f(x) = -1 and 1.

I think these are the simplest examples I can think of.

Week 11

I heard about Alan Turing previously in cognitive science. We were studying the evolution of computers playing chess, and Alan Turing was one of the first to build a machine to do so. For a computer to beat the top player in the world, it has to be able to computer combinations of moves into the future. Your standard novice game might only look 1-3 moves into the future while the top player was able to look 20 or so moves into the future. Once the computer was strong enough to compute that far into the future, Deep Blue I believe was the first, it was able to beat the top players.

Week 10

L'Hopital's rule was something I learned last year in calculus or maybe in grade 12 calculus. To solve these implications, isolate the constant c on one side of the inequality, then use L'Hopital's rule to take the derivative of the top and bottom. I'm a little unsure of what the actually meaning of Omega is. I understand have to prove it, but just not sure what the practical description of it is. While learning big O, we analyzed the code and counted the worse case. I'm assuming that big Omega bounds the best cases from the bottom. I will have to look into this.

Week 9

In this week, the 3 while loops would have had me initially guessing O(n^3). However, when we looked closer, the loop guards were much smaller than n. But then again, we have to multiply the 3 1/3n rather than adding the 3 1/3n to sum to n of power 1. So initially, I was right, but the picture showing i,j and k split along n made me thing that it was O(n) but I was correct in my first naive approach. Disproving or proving it is not an element is pretty textbook here too. Just use negation and prove that.

Week 8

Although I learned about analyzing Python functions and matching them to their respective big O last year at Queen's, this week reinforced my knowledge on the subject. In the first example this week, we found the worst case to be 3n + 3, however in my last year, we would have just said O(n) instead of diving into specifics. We never dove into proving them though, so this was new to me and wasn't covered in the first year computer science program at Queen's. However, it was a pretty straight forward extension of what we already learned earlier in CSC165... Assume or select the variables, assume the antecedent, prove the consequent by finding the existential variables.

Wednesday, November 19, 2014

Week 6

I already used floor and ceiling a number of times before, so the concept was not new to me, just the formal definition. This week, there was only 2 classes and they were both solving example problems, so there's not too much to talk about. In the proof ∀n ∈ N, n^2 + n is even, I am wondering why it is better to factor it to n(n+1), why can't you just try n as an odd and even in n^2 + n? Here I will do it without factoring. It's obviously not a formal proof, just a confident thought process.

Let our even number = 2
Let our odd number = 1

n^2 + n
Odd n = 1^2 + 1 = 2 = Even

n(n+1)
Even n = 4 + 2 = Even

n*n will always produce an even if it's even and odd if it's odd. Adding 2 odd produces even and adding 2 evens produces even also. It's all evens!

Saturday, November 1, 2014

Week 7

We received a problem in class called "penny piles". Starting with 64 pennies in one drawer and none in the other.

2^6 = 64
2^5 = 32
2^4 = 16
2^3 = 8
2^2 = 4
2^1 = 2
2^0 = 1

This pattern sure looks a lot like how binary numbers are calculated!

You can move half of the drawer to the other, as long as it contains an even amount of coins. The even numbers seem to be the easiest to achieve the most of. The odd numbers raise the most obvious concern. I think I will look at a few examples to examine this first.

64 achievable
63 will have the steps (64,0), (32,32), (48,16), (56,8), (60,4), (62,2), (63,1)
62 achieved above.
61... that will correspond to 3 on the other side. If I multiply 3 by 2, I can see some of the path that will lead me to 3. So: 6, 12, 24, 48. So now, 61 turns to getting to 48 and then halving to 3! We know 48 = 2^5 + 2^4 = 32 + 16... (64, 0), (32, 32), (48, 16), (24, 40), (12, 52), (6, 58), (3, 61). This may be a systematic route for a program...

We will work backwards to find a path, then trace that path back from (64,0).
Step 1: Take the lower of the 2 values that sum to 64. Ex: 3 in (61,3)
Step 2: Multiply that number by 2 until you hit something that can be expressed as combination of a base of 2.
Step 3: Work from (64,0) to that combination of base of 2. Ex. If it's 48 then 32 + 16
Step 4: You can now halve that number until you get to your goal.

Who knows how much this will work, but definitely something I could code up in Python pretty quickly.

Wednesday, October 15, 2014

Week 5

Test #1 was not too bad. The only part I didn't understand was the question where the 2 logic statements were identical, except for the order of quantifiers. I didn't know this mattered. I always assumed ∀x, ∃y was the same as ∃y, ∀x. However, I checked over the Wikipedia page on Quantifiers and it seems of course it does matter.

They used the example ∀x ∈ N, ∃y ∈ N, y = x^2 and ∃y ∈ N, ∀x ∈ N, y = x^2. The first statement is true, but the second is false. Previously, if they were written symbolically, I would have said both are true. When I write them in English, it's of course a lot easier to understand and explain why both are not true. Actually, even if you wrote them as Python/pseudo syntax with proper nesting, it would be better.

all(any(y==x**2 for y in naturalNums) for x in naturalNums)

any(all(y==x**2 for x in naturalNums) for y in naturalNums)

Monday, October 6, 2014

Week 4

I found the assignment to be reasonably easy for the most part. 2d) really tricked me. I saw it was the inverse, but decided to word it as "the converse of the contrapositive" which I thought would be a safe bet. Initially I found number 4 hard, which probably should have been the easiest one, but quickly figured things out once I realized that some of the sections could be empty. It was late and I shouldn't have assumed that. Lastly on number 5, Professor Heap explained in class it could be both, so I assumed there must be one that was both. I couldn't find one that was, but in the answers it appears that, of course, there was. Now it's time to make the aid paper for the test on Wednesday and luckily the notes include a couple handy and comprehensive pages of logic formulas.

Monday, September 29, 2014

Week 3

In Friday's class we had an interactive problem solving session where we had to find the pattern generated when we folder a strip of paper. To solve the problem, my partner and I looked at the sample data we had. I saw the length grew at a rate of 2 times the previous length plus 1. My partner quickly found that it was a recursive operation where the previous folder pattern was not only a subset, but ended with the previous set's pattern. Next we looked at the middle item of each sample pattern, and it was the always the same. Lastly I found that the first part of the pattern was a reverse and inverse of the last segment of the pattern. My partner started to code this in Python using strings, but I advised that maybe we should use True and False to represent up and down because in Python to inverse we can just use the keyword not and we can easily do the reverse and inverse operation with the following lines of code:
previousData = [True, True, False, False]
firstPart = [not x for x in reversed(previousData)]

Thursday, September 18, 2014

Week Two - First Post

Hi! I'm Josh, a transfer student from Queen's. I'm taking CSC165 as part of my computer science degree along with CSC207. Although I've used the all and any built-in functions a number of times in my own Python software, I was still able to learn and benefit from the recap in class these past couple weeks. Some of the experiences in some of the last exercises of "natural language" on Wednesday were tricky, like "Don't knock it unless you've tried it." I'll have to memorize the implication, contrapositive and converse. Other than that, the first couple weeks haven't been too bad. Looking forward to what's in store next.