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!