Processing math: 12%

Tuesday, December 8, 2015

Update 2

I'm just over a week into the CS Course. I spent most of the last week working on SICP. Now, I have conflicting ideals fighting it out in my head. One side says I should look at the bigger picture and be content with being a generalist, the other says I should master what I touch. Spending 2 hours at a go on an exercise in the SICP book (in the first chapter no less) does raise questions: if I'm having this much difficulty now, what about later on? Then again, the voice of life experience chimes in: what is easy when you first start it? Not martial arts or any kind of physical training, not math, why is CS being difficult... when I'm alone teaching myself... why should that be special?

Watching the 2nd CS61A lecture w/ Brian Harvey made me feel a lot better. Here is a legendary professor and even he is making mistakes and forgetting things on screen. Aha so the world is filled with humans, not wizards. That's good.

In the end it was more of an emotional realignment - whatever that means, I think I just made it up. I don't have to be a Wozniak-level master at everything I touch - and I am on a timeline - so for the exercises: I'll read through them, attempt them, give it some time, then check the solutions online. There are 2 things I'm determining as important: that I struggle and try to assemble the logic of how the functions should be constructed, and that I decipher the reasoning in the solutions. I need to understand what's going on and why.

Another thing is, it looks like I've been making myself suffer just a tad too much. I'm reading before I watch a lecture. I've finished 1.3 of SICP, (still have some exercises from 1.2 and 1.3 to go through today) putting me on page 107. For the MIT 6.001 course that places me at around the 4th lecture, and for CS61A that's week 2 or 3... heh so I read ahead. But that makes the material in the lectures seem a hell of a lot simpler now. It's basically a smart guy talking about stuff I had to figure out on my own... which actually does a lot of cement it all. I'm liking it.

I started a GitHub repository to document all my coding work/notes in one place. GitHub.com/WNoxchi I think this also adds a layer of ... what's the word... accountability? trust? anyway, that; so it's not as if I'm making up an elaborate story on a blog. The work's there, the time stamps are there. I actually decided to set up an account after impressing myself. I coded the Fibonacci sequence in Scheme right before my eyes, typing as I spoke the pseudo-code to myself next to my sister. That Rain-Man moment was quickly followed by headache but it was uplifting.

Fibonacci:

(define (fib n)
    (fib-iter 1 0 n))
(define (fib-iter a b count)
    (if (= count 0)
        b
        (fib-iter (+ a b) a (- count 1))))

Exercise 1.11 in SICP asks to define a procedure recursively and iteratively that computes the function:

f(n) = \{n, if  n \lt 3 \}
f(n) = \{f(n-1) + 2f(n-2) + 3f(n-3), if n \ge 3 \}

Which isn't too hard to do recursively:

(define (f n)
    (if (< n 3) n
        (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (-n 3))))
        ))

It does exactly what the formula says: if n is less than 3, return n; otherwise: add f of (n - 1), 2*f of (n-2) and 3*f of (n-3). Now, if n within those 3 function calls is greater or equal to 3, the function calls itself again and creates another 3 branches for each instance until the condition: (n \lt 3) is true. Then the procedure goes back up the tree, (or they look more like roots I guess) adding and multiplying as specified until it returns a single value.

That makes sense. Now.. how do I do that iteratively? I tried writing out the process on paper but 15 minutes in I was still lost. I have the solution from online, but I'll need to take time today to understand it.

Of course, there are much greater hurdles waiting just behind the door. I need to build a procedure that determines prime numbers by factoring, and something that does something by successive squares but I have to check the description. Fun.

But there is a feeling, at this point more like an echo of a shadow of it, of overarching power, or competence, or just the feeling and state of mind you have when you just know how to do something. On an instinctual level that may be what I'm chasing. What I know is I feel this magnetic draw to this entire field, of Informatiks and technology, and I've learned the hard way to listen to those instincts.

Another cool thing from a lecture: apparently Computer Science is a terrible name for the field. What it really is, and the name used in a bunch of European countries, is Informatics. I may spell it with a 'k' because why not. Anyway, that's the update. It's a lot of baby stuff right now. I'm still far off from being ready to attempt the problems at Project Euler. Since it'll be a little while until I'm able to buy my own Mac, I think I'll dual boot my main machine in Linux. All these CS classes use the UNIX command shell, so I better get familiar with it. Also I'll be able to play Kerbal Space Program without memory limits )))). I'm thinking Ubuntu Mate or LinuxMint Cinnamon.

Gonna read more of Superintelligence before I say something about it.

No comments:

Post a Comment