Friday 23 November 2012

Wiki Assignment and Koch-curve - Week of November 19th

I just finished the third part of the wikipedia assignment and ran into something I had not been expecting (I suppose I should have written a check-expect).  One the the pages I was meant to edit has already been fixed.  This doesn't seem unreasonable to me, I could hardly expect the wikipedia world to know that I intended to do that later on and to wait until I had time to do it.  None the less, it does beg the question, how am I going to get graded on the assignment? I did put considerably more effort into the second page I edited to try and compensate for this so maybe the weight will be shifted onto my review of that single page.  Alternatively I could have found a new page requiring editing and done it on the fly, although that would have felt a little rushed.  Either way I did have a good look at the wikipedia process and community which was I believe the purpose of the assignment.

On another note, I recognized the koch-curve we worked with in the last lecture relates to the material in my analysis class.  If we were to take a koch-curve of infinite iterations then it would be continuous everywhere and differentiable nowhere, which is kind of cool if your into that sort of thing. The reason being is that there will be a 'bend' at every point on the curve, and we can take the derivative of a function at a 'bend'.  Not really computer science so far as I know but I thought the connection would be worth mentioning.

Theo

Saturday 17 November 2012

DrRacket recursive definition - Week of November 12th

I never did have much time to think of a way to take the sum of the areas of the pyramid levels, not yet anyways.  I did figure out how to make drracket do it 'the long way' however.  I used the recursive definitions we learned in class to make racket take the sum of the bottom layer of a pyramid then work its way up. It was pretty straight forward and looked like this

(require picturing-programs)
(define (sum n) (/ (* n (+ n 1)) 2))
(define (vol n)
  (cond
    [(equal? n 1) 1]
    [else (+ (sum n) (vol (- n 1)))]))

It does feel a bit like cheating and I do still plan on trying to think of a single expression for the volume. It is neat to see so easily that the 'volume' of one of these pyramids with a bottom side of n=200 is 1,353,400 bottle caps. 

Theo

Wednesday 7 November 2012

Recursion and Clock Project - Week of Nov 5th

Regarding the ongoing algorithm project, I have not had a chance to work out a formula for the sum of the areas of triangles that make up one of the pyramids; but I do hope to find some time this weekend.  I did notice today in class however that the algorithm I am searching for fits with the definition of recursion.  Given some n we can calculate the A, then if n-1 is not zero, then add the A' of the row with sides length n-1 to A, and so on until we come to n-n=0 and we stop.  I suppose if all else fails I could just use a conditional in DrRacket that takes n->V.

Having just finished the first project I feel much more confident in my DrRacket skills than ever before.  I did get stuck on the clarify-image definition for a while but thankfully Professor Heap sorted that out in class.  Before that I had tried to convert the image to a list, then map the function clarify-color to every element of the list, then convert this updated list back to and image.  I would have made it work too if it weren't for the width and height arguments needed to put the image back together properly.

I changed the hands of the clock for the project to three thin black rectangles (classy and understated in my opinion) but soon realized that half of the definitions that needed fixing were totally unnecessary if we weren't using an image in a box like the ones given.  So it was interesting to see how we could simplify the clock but I figured it would only lead to confusion if the new hands I had created weren't using the definitions that we were required to fix or write check-expects for, so I kept the original ones.

Theo

Thursday 1 November 2012

Bottle Cap Algorithm - Week of October 29th

To work at the algorithm I set out to find last week I made a chart comparing the length of the side of the bottom most triangle, the 'area' of the triangle, and the 'volume' of the pyramid for 5 cases (i.e. base triangle with 1 bottle caps through length 5).  I noticed that the area of a triangle for any number n of bottle caps on one side is going to be n + (n-1) + (n-2) + ... +1 = A.  This can be expressed as (n(n+1))/2.  If your willing to take my word for it that thats true then don't bother reading the next paragraph.

In case you are the sort of reader who would demand that this be proved, which you are certainly entitled to do, the simplest proof is that by induction.  We know the formula holds for n = 1, since 1 times 1 + 1 is 2, which divided by 2 is 1, the A we should expect.  Now let us assume the function is true for the natural number n, then we shall see if that implies it is true for (n-1).
A(n-1)=((n-1)((n-1)+1))/2 = ((n^2) - n)/2 = ((n^2) - n + 2n)/2 - (2n)/2 = ((n^2) + n)/2 - n = (n(n+1))/2 -n
which if true for n implies A(n-1) = A(n) - n = n + (n-1) + (n-2) + ... + 1 -n = (n-1) + (n-2) + ... + 1
Which is exactly what we are looking for. Since our function is true for n=1 and if it is true for any n it is true for n-1, then it is true for all natural numbers n.

So after finding an algorithm to find the "area" of a triangle arranged in the way described last week, it became clear than the "volume" of one of the pyramids would be a sum of the areas of all the triangles that make it up.  However, we cannot simply take the bottom area, say An, and then plug that into the same formula above because An-1 won't be the next natural number.  So we have to find another way to take the sum of An + An-1 + ... + A1 = Vn.

I'm going to try and think of a way to put this in a closed form as we did above for finding A.  If we can find an algorithm for mapping some An to Vn then we can consider the algorithm that takes n to An and then the algorithm that takes An to Vn.  This will be a composite of two functions, maybe it makes sense to consider this a composite algorithm.

Theo

Tuesday 23 October 2012

Searching for an Algorithm - Week of Oct 22

Now that we have covered algorithms in class I have started to think of a problem which I could try to develop an algorithm for.  I worked through the paper folding exercise given and got some practice working with the patterns and trying different approaches to the same problem.  What I liked in particular about the paper folding algorithm was that it mapped a natural number n to a pattern.  That one single number can contain not only the number of up folds and down folds, but the order that these folds appeared in as well, that really impressed upon me how powerful algorithms can be and given on of these 'recipes' how much information can be stored in a single number.

A problem that I would like to solve myself goes as follows:
I want to arrange bottle caps into pyramids.  I will start by making an equilateral  triangle of bottle caps with side length n (where n is some natural number of bottles caps, it would be tough to use a fraction of one or a negative number of caps) then I will make another such triangle with side length n-1, then stack this smaller triangle onto the larger one, and repeat until I get a triangle of side 1 on the top (not much of a triangle I know but none the less).  I want to know if I start with a side of n caps, how many bottle caps will it take to finish the pyramid.

I will probably try and solve in by considering the total number of bottle caps in each level and then add the levels.  Maybe I could come up with equations analogous to area and volume for the triangles and pyramids respectively.  Also I could make a chart of different values of n and the corresponding values for the total number of caps and even some other values might be helpful.  I will work on this here and there and see if I am any nearer to a solution next week.

Theo

Tuesday 16 October 2012

Post Term Test - Week of October 15th

With the first term test in the rear view it feels like we are really in the thick of things now.  The test didn't have any questions that I felt were unfair or unreasonably difficult.  Much to my surprise I froze on the binary multiplication, it wasn't that it was in base 2 (that as I've said I am fairly comfortable with) but I forgot how column multiplication works!  I'm sure I could have worked it out but for the time constraint.  An hour goes by pretty quick when your writing a test and I felt that even another 15 minutes would have given me a chance to review my answers and catch anything I missed.  All in all though it was a fair test and I can't complain. I am going to put a little more emphasis on this weeks tutorial exercise this week than I have in the past.  By working on it tonight I can get a feel for wether or not I will be able to finish the exercise and grasp the concepts in the one hour of the tutorial on wednesday or wether I will need to commit more time to it.  I think that becoming more comfortable with the tutorial exercises will better prepare me for the next term test.

Theo


Tuesday 9 October 2012

Base 2, DrRacket... and SLOG? - Week of October 8th

This blog is a first for me so I am not sure exactly what I am supposed to say to whom, so I will start by introducing myself.  My name is Theo and will be keeping a course log (or SLOG if you prefer, I don't) for CSC 104.  I am a first year student in math and physics just to give some perspective.

I'm kicking myself for letting this assignment sneak up on (and past) me, as I am working on this a day late.  The biggest pitfall for the one day a week class has been letting myself forget about it until the day of.  I have decided to put a reminder in my calendar to check the course website at least one other time during the week.

So far the course content has been manageable.  The history covered in lectures in interesting though I am glad it is kept brief.  Fortunately I have seen fields in base 2 in my Math courses already so this is one less thing to worry about.  If I have any advice for people who are struggling with the idea, it would be to consider the similarities with base 10 (regular every day numbers), the two really aren't as different as they seem at first.

DrRacket on the other hand has been a small but very real source of stress for me.  The tough thing for me is to remember the different functions and how they work with each other.  For instance, rotating an image counter-clock wise was simple and given in the tutorial exercises, but trying to remember how to rotate an image by degrees was a fruitless endeavour. Armed with only the word rotate, an image, and some number of degrees, I tried a variety of different combinations with no success.  To remedy this I will be making more use of the picturing programs pdf.  As if that were not frustrating enough, DrRacket (and I suppose programming in general) is so incredibly pedantic that nothing seems to work on the first try, and rarely the second.  One redeeming value however is receiving an error message that tells you what it is that is not working.  That is a luxury I do appreciate.

This brings to an end my first weekly log for the course, hopefully I don't get drilled too badly for being a little late with my first entry.  Good luck to everyone with the test tomorrow!

Theo