LP: 8.01x Classical Mechanics, Week 1

As I’ve explained in my previous post, I decided to take an MIT course for my Learning Project, CS-Harvard.

Week 1 of Professor Lewin’s Classical Mechanics course was very interesting, to say the least.

The first lecture involved studying about Units, Dimensions, and Scaling Arguments. The very start proved to make a point that this is going to be one fun of a course: minutes into the lecture, we see Professor Lewin hauling a huge Elephant femur, it being compared to femurs of other animals. The sight of a 70±10[1] aged professor carrying an animal bone about half of his size was awe-inspring, second only to Sir Malan’s book-ripping introduction.

The second lecture was an Introduction to Kinematics, introducing basic concepts such as velocity and acceleration, and most of this is one-dimensional.

The third lecture, which was about Vectors, was pretty interesting. A vector’s magnitude, dot products, vector products, ballistics, were among of the many things brought to attention.

The lecture ended with a quite interesting experiment – a missile in movement throwing a ball and catching it back -showing that the decomposed vectors were independent of one another. It was pretty novel seeing a ball zipping through the air in a classroom, and I invite you to watch it for yourself (video found at the bottom).

I was caught a bit off guard by the Homework though, because it required calculus[2] to solve! While the course lists Single-Variable Calculus as a co-requisite, I did not expect the course to require it so early in the course (it’s the very first Homework!). Anyway, I simply browsed the internet for basic Calculus concepts, enough to get away with the homework, and I’m proud to say to have been able to get a solid 86 points for a 100%!

Week 1 was taken in one day, to stay in schedule for CS-Harvard.

^ Because any measurement without knowledge of the uncertainties is meaningless!
^ Unlike Scott Young who took the MIT Challenge (here for more information) I have not yet graduated from College by the time I took the Challenge. Hell, I’ve yet to go to college! This means I do not have previous calculus experience.

LP: 8.01x Classical Mechanics, A Cross-enrollment?

If you’ve been following my blog for a while now, you’d know of my latest Learning Project, CS-Harvard, where I try to complete the 4 year Harvard Computer Science Curriculum in 1 year.

This suggests that I’d be taking Harvard Classes in a very quick pace. Of course, this is true, but I decided to spice things up a bit. Why limit myself to Harvard Courses?

The Harvard Challenge, being well, the HARVARD challenge, aims to mirror as closely as possible the coursework of a Harvard CS concentrator. However students cross-enrolling are not unheard of, and one or two courses from different schools couldn’t hurt the challenge, right?

That’s why I am planning to take the Classical Mechanics course offered by MIT through Edx for my challenge.

Gotta love Physics

I have always absolutely adored physics, and to say that it is my favorite subject is not too far from the truth. Physics is the absolute representation of nature, and the moment I was introduced to the subject, I knew that I would forever love it.

The Classical Mechanics course by Prof. Lewin that I am planning to take is quite famous; many of the course lectures had been shown on TV, and it was the pilot course taken by Scott Young for his MIT Challenge (for which my challenge was inspired from), among other things. The fact that it is now being offered on Edx is a very definite plus and I can expect an improvement in the overall experience of taking the course.

Because of the fact that I’m taking the course through a provider, namely Edx, I can’t take the course in my usual 2 week phase (Unlike Edx Harvard courses which allow you to do so). Because of this, I will be taking another course in parallel, Math1a.

LP: CS61: Problem Set 1 – A Debugging Malloc Library

Proceeding from lecture 4, the next lecture involved studying nifty things like how garbage collectors are implemented. This is eased to by first studying memory allocation and the different storage durations; static, automatic, and dynamic, along with the three’s respective advantages and disadvantages. It was pretty obvious as to what they were, however.

The assignment was a pretty colossal task though: It involved writing a Debugging Memory Allocator! The assignment caught me off-guard; I couldn’t even begin to imagine how I would write something like that.

The assignment was pretty challenging, redefining C’s malloc (which is how C allocates memory) so it carries meta data for debugging purposes.

Malloc Diagram

Making a Diagram for the Problem Set was incredibly useful (Visio ftw!)

I now understand though why it was important to be in the same infrastructure when taking this class (though CS50 and CS51 offers their own infrastructures, both of them allows you to ‘go with your own’). The sequential allocation and clearing[1] of memory were perhaps the most (reasonably) important things in it, because it made allocating meta data easier.

The first parts involved setting up the header and only returning the contiguous ‘free space’ so that the metadata would be untouchable by the programmer (or at least, conceptually). Things such as padding is quite important so that we can access the header through address arithmetic.
Going through the problem set made the metadata more sophisticated, as the features of our library. The need to check for boundary writes meant that we also needed a footer metadata, and memory leak reporting meant that we had to somehow store all the metadata in a data structure. This is accomplished through a doubly-linked list.
What was interesting was the later challenge of a diabolical free. The test copies the block of memory, frees the original block, and then copies it back to the destination. This sets up the memory as if it has never been touched, but our debugging library does have to take into account such events!
Writing this debugging malloc library was one of the best programming Problem Set I’ve ever completed. It was both conceptual and practical, and while it took me a bit to complete it (2 days, still on schedule for the Harvard Challenge), I would say that it was all good!

^ It sure seems to be set up that way. There were also quite a few things I did too to check for a valid header, including a hash that get’s checked, among other things.

Keeping At It – 3 Tricks to Accomplish Goals

When a friend of mine saw that I was doing the Harvard Challenge his initial response was “No way you’ll be able to complete Harvard’s CS Curriculum in one year. Even if you had the mental capability to do that, I can’t imagine anyone being able to sustain such a routine.”

After his melodramatic reaction, I proceeded to show him the math – it is in fact possible to complete the 4 year curriculum in one year, though admittedly there are some corners cut (no rubbing shoulders with fellow students nor college parties, etc.)

Convincing him that the time allotment is actually sufficient, he was still skeptical on how it would be possible to keep such focus on one task. Surely willpower would have to fail one day?

His reaction prompted me to pause and reflect: How could I sustain the routine? The following three tricks were the ones that bubbled up to the top in my mind, and are the concrete things I really did.

1. Pomodoro Technique

A Time management technique where you allot a block of time, usually 25 minutes, for a task, and then taking a break afterwards. This is a very effective technique for those who find themselves procrastinating when they should be working: Whenever you get the urge  to do something that is not related to the task at hand, make a mental note of it. When the time is up, go ahead and do it, maybe even check email. The break normally lasts for 5 minutes, and after that, you’re back to working again! If you stick to it and complete four 25 minute chunks, you get a longer break.

It helps to have a physical timer (like the one on the picture) that you unwind. However, if you prefer something more digital, pomodairo is an excellent, free, open-source, multi-platform application that I too personally use (Not Affiliated with it in Anyway!)

2. Goal Setting

Not setting goals is perhaps one of the most common mistakes out there, despite the fix being insanely easy to do. Basically, just make a practical, actionable goal! Do not set abstract goals (I’m going to write the next breakout novel!) or something you’re not willing to stick to (I’m going to fix that door one day). Make clear goals, with clear deadlines, and you’ll see your productivity skyrocket in no time.

For example, in my very first major learning project, CS-Harvard, I decided to complete the whole 4 year curriculum of a Harvard Concentrator in one year. The goal is very clear (a 4 year curriculum) and the deadline is too (completed in one year). The big picture goal is further subdivided- I plan to complete two courses a month, one problem set every two days, etc. etc.

3. Keeping Momentum

The third, and perhaps most substantial technique that I can personally see, is, put simply, STICK TO IT! Keep Momentum! Make it a Habit! It is much easier to do something if it’s seemingly wired into you, and that doing it is already part of your routine (it doesn’t even have to be a daily routine!)

For example in CS-Harvard, a three-day hiatus was probably the biggest threat to my challenge: I found myself incapable of keeping up the consistency of completing a Problem Set A Day, even though I have been dishing them out with no sweat a few days ago. The reason was apparent – I ‘came out’ of the loop. After a few days easing myself back to the routine, I became productive once again!

Though only a handful, these were three concrete tricks I actually used in completing my Learning Project. If you know of any useful tricks, why not comment below!

LP: CS61: Meet Bits- Bases and Dynamic Memory Allocation

Being a Systems Programming course, I was expecting a bare-metal approach to computer programming, and boy was I right!

The first few lectures involved discussing Information Storage in a modern computer, and things that arises from this representation such as Integer Overflows and Bitwise Operations. Bitwise Operators were discussed in CS50, though are still crazy operators (as CS61 attests to). Come third Lecture in the course and I already found myself diving into Computer Arithmetic and Machine-Level Code, making sense of bit patterns and anomalies in signed arithmetic!

And in the 4th Lecture, it’s already deep computer science galore as we look at deeper representation concepts such as Big Endian and Little Endian and even Memory Padding to keep Data Structure Alignment.

Little Endian Diagram

Little Endian Diagram – How Data are stored in your computer

CS51, which was the last course I took for my Harvard Challenge, was an Abstraction and Design Course, building up abstractions, involving nifty stuff such as  code making code for me. CS61, which I already explained in my previous post, takes the opposite direction, driving through abstractions and learning the ‘engine’ of the computer.

CS51’s code was beautiful to look at.  If CS61 is the opposite, by that logic, the code here is UGLY.

Which is really something to be expected, because really, you don’t expect the innards of a car’s engine to be as clean as the outside. Nope, in fact you know it’s a sea of molasses full of wires, traps and maybe an exploding bomb. Okay, maybe not that exploding bomb bit, but you get the point.

The first assignment (again zero-indexed) was pretty basic but still pretty tough, if maybe time-consuming. The first part involved converting to different Base Systems (e.g. Decimal to Binary) by hand, while the next parts involved Bit operations and a handful of C Code.

You can view my Assignment 0, Here.

LP: CS61: First Day in Systems Programming

Finishing my last course from my Harvard Challenge, CS51 brings my total number of courses completed to 5! Huzzah!

For the next weeks, I have decided to take CS61, which is a Systems Programming and Machine Organization Course. Unlike CS51, which is an Abstraction and Design course, CS61 offers to go in the opposite direction, driving through abstractions to really see what makes a program tick. This empowers programmers to write really optimized programs, because, how would you expect to write really good ones if you don’t know what’s going on under the hood? In fact the first lecture shows just goes to show how big a speed difference an array implementation is from a linked list, due of the fact that memory is not contiguous in a linked list, making it take longer to access.

Skimming through the syllabus and sampling some of the course material, it’s looking to be a very exciting course, tackling complex C programs, simple binary programs, and even assembly, interpreting how compilers turn programming languages to instructions, and how we can optimize them.

PS: This might just be the very first technical course that does not reference XKCD!

LP: CS51 – Wrapping Up, Cows and Finals

That’s it! CS51’s end is on the horizon, and I am again one step closer to completing my Harvard Challenge.

Problem Set 7 served to culminate most of the concepts introduced in the class, while also serving to expand events and objects. The last problem set involves programming a pseudo-simulation of cows in their natural habitat, or so I’ve described. A video of it in action, plus the specification, is available in the official page here.

The problem set is divided into 6 parts (along with a table of contents even!) so you know its going to be loads of work. There wasn’t really any pset that used objects before this one, so most of the concepts like Inheritance were introduced here. Coding a movable class to which bees and other moving objects inherited from meant a lot of code re use.

Movable Object Diagram

 

Perhaps the only thing I was uncomfortable with in the whole program was the fact that World Steps were events, and object adds an event listener for it, instead of having a world object that calls the ‘update’ method of it’s children. Of course, it may be just because of the fact that the pset aims to introduce the students to events, so it’s fair enough.

Finals

I took my finals today, and it went smoother than I expected. I was able to ‘steal’ a flash card reviewer for the final exams’ course, which I can only assume was the work of a previous harvard student or a TF. All in all it took me about an hour to complete the exam, including formatting the questions to make it look at least look easy enough for the eyes.

I nabbed a 95/100 for the exam, which you can view here. Of course, it was self assessed,, but most of the questions had concrete objective answers (definitions, true or false, code). There were a handful subjective answers, but I decided to grade them brutally (perhaps too brutally even!) I am even surprised myself that I was able to get such a high mark, though I can only imagine that the problem sets, which were the real meat of the course and involved lots of thinking and code, were the real barometer for the grade (or maybe Harvard is just that effective in teaching!)

The last question on the finals “What is the super secret bonus answer?” which was worth 1 point. I guessed “Cows” but I was unfortunately wrong. (The answer was 43)

Wrapping Up

Alright! I’ve finished CS51, completing the systems requirement of Harvard’s Computer Science Curriculum. I learned a lot in this course, being it functional programming and the beauty of abstractions (and laziness!) The syllabus states that the goal of the course is:

CS51 is a course that will teach you more rigorous methods of developing and
analyzing software. You will learn to write code that is reliable, efficient, readable,
testable, provable, maintainable… beautiful!

Which I think I was able to accomplish.