Thursday, 14 February 2013

The Logic of Like

(Warning: the following ramblings involve a high probability of dangerous to near-fatal overflow of possibly quite putrid cheese. They also have about zero relevance to CSC165, because on (frequent) occasion my brain wanders away from the astoundingly brilliant thralls of logic (so... whoops). Prepare yourselves accordingly - I'd suggest with a well stocked wine cellar. Well, except for you unfortunate underage firsties...which may be the majority of people in this class. Ah well, not like you'll read this anyway, but still, sucks to be you guys!)


So, I missed the mark by about 2 hours (because every sane person'd rather code stupid CSC148 projects than go out and get drunk with people right? Though I shouldn't complain, since I dabbled in both today), but Happy Free-Chocol - er...I mean Valentine's day! That one. (But also "Free Chocolate Day." And also "Sh**Ton-of-Consumerism Day." And also probably many, many others.) Yes.

So, I've got a story.


Unlike what an apparent majority of people and TV shows like to say, I actually had a great experience in High School (and no lockers were harmed during the course of my adolescence.) It probably helped that my parents shipped (well, bussed) me off to a private school for a few years, which had an impressively competent (and interesting!) set of teachers.

My favorite was probably the math teacher. For being completely grey-haired, he was an incredibly chipper and completely dorky guy (on the rare occasion that it snowed more than a centimeter in winter, he'd take his preschool-aged kids out and make TI-83 calculators instead of snowmen (complete with graphs!) and then - predictably - take pictures to show to the gaggle of estrogen-laden teenagers in his Calculus classes. "Right on!" (yep, he also talked like a wanna-be surfer. Don't ask why. Nobody knows.))

Anyways, it was during one of these glorious Calculus-ignoring occasions when he nonchalantly pulled out an unhealthily-pink napkin heart-stamped containing illegible scribbles out of his pocket, leaned against the table at the front of the classroom, and imparted the following story to the amassed flock of girls about an event that had happened at his daughter's preschool the other day.

On the day in question, he'd arrived to the school early, and found that his daughter's class was in the process of reading a story. He figured he'd wait, since there were only 10 more minutes or so, and went to sit down in a nearby corner to twiddle his thumbs for a bit. It was after a few minutes of sitting that he noticed one of the boys in the class - a friend of his daughter's - edging closer, and finally coming to sit down next to him. 

"Hey there, buddy, how's it hanging?" He tried, only to get an enormous soul-wrenching sigh from the boy. 

"Mister," the boy said morosely, "how do you know when you like someone? Cuz I think I may be half in like with your daughter."

"Half in like?" He asked. "What do you mean by that?" (and, ever the opportunist, fished out the gaudy pink napkin and a pen from his pocket to transcribe the sure-to-be-amusing response.)

"Well," the boy began, thinking deeply, "I like playing with your daughter at recess the best, and when I'm with her and she smiles I get a warm fuzzy feeling in my tummy. It's getting warmer every time I see her. I don't think it's full like yet, only half like, but  I think maybe that'll change one day. Anyway, I just wanted to let you know that's how I feel." The boy finished, and quickly shuffled away as class ended and children dispersed, leaving my professor quite speechless.

"And that," my professor concluded to the enthralled mass of girls in Calculus, "is probably the best definition of 'like' and 'half like' I have ever heard, and it was said more concisely by a 5-year-old than any adult ever could!" (The girls, predictably, sighed and squealed like the fangirls they were.)

Cheesy as it is (and man is it! It's almost painful writing it), I still remember this story every Valentine's day, and like my prof, all I can think is "Well said, little guy. You'll go far with that logic." (It certainly won over every girl in my class! Hats off to the future him for his luck with the ladies.)

Valentine's isn't special (though it does involve chocolate, and that - if nothing else - has merit.) Even so, hope you all had a good day (and happy chocolate hunting tomorrow - yay sales!) Cheers.

Wednesday, 13 February 2013

Week the Fifth (in Hindsight)

Aaaaand it's all about proofs! Though it was cut short by that test I mentioned (which went decently, I thought, in case you were hanging off the edge of your seat in anticipation.) Still, 2 lecture's worth of material is enough to lay a decent introduction to the methodology of proofs (...that's not to say, however, that I'll have much to write about this week. I've a feeling that this post, like the week's lectures, will be cut rather short.)

Onwards! As mentioned last time, Danny's rather obsessively preached the importance of structure in the proofs. (I think that part of the lecture has by far overlapped all others at this point.) But in between the indentations, he's also mentioned a few examples of actual proofs, and showed us how to go about tackling them.

Memorably, sometimes proving things in one direction is easier than in the other (for instance, proving that for any real number n, n being odd implies n^2 is odd is much easier than proving that n^2 being odd implies n is odd.) In cases like these, it is therefore useful to think of a way to invert the problem. Lo and behold, the contrapositive exists! (So use it. QED.)

Also memorably, in trying to prove things like "there exist an infinite number of primes," you can use proof by contradiction (assume the opposite is true - there is a finite number of primes - and try to disprove that.) So, it goes something like this:

Counter: there exists a natural number n such that n is larger or equal to the largest positive prime number.
           assuming that the universe's primes are all in the finite set P = {p1, p2.........pk},
           you can deduce that there is a number m that is the product of all these prime numbers
               (m = p1*p2*...*pk), and is a natural number since all primes are natural and this set is  
               closed under multiplication.
           then m is some number that is ultimately greater than 1 (since p's are greater than 1)
           then m + 1 is greater than 1 (because of above)
           then there exists a prime number p that exactly divides (m + 1) (since every natural number
               greater than 1 has a prime factor - if prime, itself, or if not, its composites)
          and p must also exactly divide m, since m is the product of all prime numbers
          then p must exactly divide ((m + 1) - m), or 1
          which implies p = 1
          but under the definition of prime numbers (one which has only 2 natural numbers that divide
               it), 1 is NOT prime, so that's a CONTRADICTION
and therefore the original claim must be true. (Yay!)
...which is probably a better proof of this problem than the following:


In case you're ever stuck on a problem, here's some useful advice from Danny: "I look up and to the left quite often, because that's where answers seem to come from." (it does explain all those thousand-yard stares during exams.)

Thursday, 7 February 2013

Week the Fourth


I've come to a conclusion: recursion is a bloody pain in the arse (though, admittedly, a rather beautiful one if done right.)

This, however, has nothing (yet?) to do with CSC165. It's quite possible that most of these ramblings won't, because this post is a week late and will therefore probably manage to center itself on the reason of lateness (aka the comp sci test we had yesterday morning, which involved - you guessed it! - recursion!! Grumble.)

Ah, what I'd give to be a Time Lord....

But I'm not. Moving on. This (well, last) week we talked about Limits, and Proofs (and probably a lot of other things that I may have forgotten to write down.)

Taking a Limit, apparently, is like waging a dismal, complex, one-turn war against your horrendously evil arch-nemesis, in which they try to make you look ridiculous by picking an epsilon which gives you a seemingly-impossible target, and you in turn laugh in their face with maniacal glee as you cleverly choose a delta in response that crushes their hopes as efficiently as dropping a one-ton brick on a piece of packing foam (which is to say, completely.) At least, that's the gist I got. It also gives a whole new meaning to "nice guys finish last" - after all, if you're the 'nice' guy picking the delta you'd better ensure you're choosing after the epsilon is set by your dashingly evil alter-ego. (as Danny eloquently put it: "Switching epsilon and delta: that is DEADLY. Don't. Do. It.") And that was, as far as my memory allows, the majority of Wednesday's lecture.

On Friday, we began fluttering about the topic of Proofs. I say 'began' to hopefully signify that I know close to nothing about this so far, and therefore have very little to say on the subject beyond the fact that apparently the TA's and Danny will be pickier with our structuring of the proof than Python running a Pep8 on a file (which is to say, excessively so.) Beyond that, I'll relay, as always, some of Danny's insights:

During our first proof of the course (n odd implies n^2 odd): "I inevitably get asked, 'Sir, what's your definition of an even number?'...as if it's up to me!" well, he said that, but he still gave us a darn good definition (even num = 2*n, odd = 2*n +1)

About proofs in general: "Some students come to me and say: 'I'm not really comfortable proving this; can't I use logic?' And that's great, because it implies 'Hey, here we have proofs, and over there we have logic, and they have NOTHING to do with each other!' " (They do. Hence the course. Oh Danny, thank god you have a sense of humor.)

And finally, for a bit of fun: "Impatience: the second cardinal rule of programmers." Which leads me back to thinking of CSC148, but hey, it was bound to happen. Thank god that test is over though. Now to worry about the one tomorrow for this course! Thankfully, I'm feeling relatively confident so far. We'll see how it goes, I suppose. Cheers!


Sunday, 27 January 2013

Week the Third

This week's most interesting activity was probably Friday's paper-folding puzzle (though, really, I doubt that's news for anyone taking the course. Who doesn't like spending 45 mins of a 1 hour lecture in Uni folding paper? It's awesome.) And of course, because it is Uni, also a bit mind-boggling at first. The puzzle is this: take a strip of paper, and fold it evenly over from left to right, and then continue doing so until you think you've amassed enough information on the art of paper folding, have found the meaning of life, cannot possibly fold it once more even if your entire future depended on it, or simply get bored (well, the last one not so much.) The point of this puzzle is to see if you can figure out the pattern in which the paper folds (whether, when unraveled, the folds are concave or converse) given the number of times it's been folded.

For example, assuming concave = 1 and converse = 0:
1 fold gets: 1
2 folds get: 011
3 folds get: 0011011
4 folds get: 001001110011011
and so on.

It took (I'm willing to admit) quite a few minutes to make sense of these observations. When I finally did, I noticed that (a.) the midpoint created by that first fold always stays the same and (b.) if you work outwards from that center, every new fold on one side is an inverse of the same-distanced fold on the other side! (genius, I know. You can do a mental 'facepalm' if you so desire.) Still, how can you get a pattern from that? Well, after looking at it a bit more in the hopes of prodding my brain into a state of usefulness, I garnered observation (c.) working again from the center, the left side is exactly the same as the pattern you get when folding it 1 time less, or: with n number of folds, the pattern on the left is the same as that of (n-1) folds. The pattern on the right is (as by observation (b.)), mirrored. Yay problem solving! Danny was right; using Polya's approach (outline the problem, concoct a few plans on how to solve it, and then attempt) is more successful than jumping headfirst into the folding.

Useful thing to remember:
A(antecedent) implies C(consequent) is false only if A is true and B is false.

Danny's quote of the week:
In talking about the usefulness of parentheses and variables: "We want to make sure there's still variables left for our grandchildren, but if we're just going from 2 variables to 4, I don't think that makes a huge difference on the store of variables in the world, so we'll probably be ok." And it's true; if ever in need, I'm sure we can move on to the greek alphabet or, who knows, maybe even use kanji.


Monday, 21 January 2013

Week the First! (and Second...and a bit of Third)

This....is harder than expected (no, not the course - we'll get to that later. Just this blog business.) It's not even that I don't like writing - for example, every November I somehow manage to delude myself into believing that it's a perfectly fine idea to write a novel in a month (yeah Nanowrimo!!). Needless to say, 3 days in I'm still staring at a blank word doc, 7 days in I've resigned myself to the fact that English is not my best friend, and by day 29 I'm thinking "What novel? Did I say I was gonna do that? No way..." (It does make one wonder why I don't succeed, considering the lengthy digressions I always make.) The point? I'm not a blogger, so sorry in advance.

So, we've finished 2 weeks of CSC165: Mathematical Expression and Reasoning for Computer Science, and started the 3rd today (we broke the rules of math! It was mind-boggling fun, especially at 11am.) I honestly don't know what to say about the course so far, so perhaps I'll just stick with a few insights that the prof, Danny Heap, so aptly stated himself:

- In week 1: Know that feeling you get when you've finally done something meaningful? That exhilarating head-rush of endorphins? (probably not.) Well you will soon! Apparently, solving problems is not only fun, but also the easiest way to get "a cheap, legal high"! Who knew math could be so exciting, and serve as a compelling substitute for drugs?! Well, now you know. Just make sure to write Danny in as a footnote on your road to success (especially if you ever solve that 'Streetcar Drama' puzzle.)

-In teaching about universal claims: "All females earn less than 55,000. To prove this claim false, you need to find just one counterexample. If we look at the table we'll see there's only one employee earning above 55,000. However, Al (60,000), is not a counterexample... because of chromosomes."

-In talking about equivalence: " If M 'belongs to' R, and R 'belongs to' M, that implies that R = M. Ok? Good, now let's avoid cheap jokes like 'same-set marriage' and move on with the lecture."

I doubt I'll ever be in a position to allot footnotes to people, but I'll keep that in mind, Danny.
Till next time, cheers.