Monday, 30 November 2015

The beauty of Fibonacci Numbers

Before Test #2 we learned the function to produce the Fibonacci Numbers in class.

Here is the sequence of Fibonacci Numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, …
And I believe everyone is familiar with how to get each number in the sequence. You just simply add the first two numbers to get the next:
0+1=1
1+1=2
1+2=3
2+3=5
3+5=8
5+8=11
...
And here is the function of Fibonacci we used in Dr. Racket to get numbers in the sequence:
; fib : number -> number
(define (fib n)
  (cond [(>= n 2) (+ (fib (- n 2)) (fib (- n 1)))]
            [else 1])) 

well, it is a unary function that produce a number from an inputed number.
n is the number of order in the sequence you want to get, and if n is greater or equal to 2 it also includes a repeated process to calculate fibonacci numbers in prior to n and then add the last two numbers.

I think the process of calculating Fibonacci Sequence is interesting. And this sequence is extremely famous for its beauty existing in nature, in science as well as in human bodies. I want to elaborate more on this findings:


Firstly when you divide one number in the sequence by the number before it, you obtain numbers very close to one another. In fact, this number is fixed after the 13th number in the series. This number is known as the “golden ratio.”
GOLDEN RATIO = 1.618
233 / 144 = 1.618
377 / 233 = 1.618
610 / 377 = 1.618
987 / 610 = 1.618
1597 / 987 = 1.618
2584 / 1597 = 1.618
Perfect human bodies, faces and other beautiful things in the world always show a golden ratio of 1.618. The ratio is used by many artist in their artworks, and by designers in their products. For example the famous Mona Lisa.









Another beautiful application of Fibonacci Numbers is the "golden rectangular"
If you draw circles using radius of 1, 1, 2, 3, 5, 8, 13... and combine 1/4 of each circle together, you will get the following image: 

This beautiful shape of "golden rectangular" is found everywhere in the nature, such as snail, shell, flowers, etc. Here are some pictures showing the beauty of nature:




















human work!




Well, it is a bit off topics from CSC104 but I find it's very interesting. There are more evidence of Fibonacci Sequence around us:) If you get some inspirations from this blog, then start to look around and enjoy the beauty of nature!

Some challenges we faced in Project I

Hi, everyone. It's been a tough week and I was busy finishing a lot of assignments, essays and projects for my other courses. I decide to do some catch-up on CSC104 first, starting with my experience on our Project I.

Since the project aims to be finished by a team of three, we firstly thought we could just divide tasks equally into three parts and let each one take responsibility of doing one part. BUT, it definitely not worked for a computer science project, once we got started we realized it was nothing like how we did for other assignments! We realized it should be a product of combining all three students work and effort together because at each step we met problems we got stacked and we couldn't think of answers by individual and that would be the time we sat together and communicated to try to find the answers.

Therefore this is how we did for Part I:
-Each of us spent 1 day writing down the answers for all steps required in the instruction.
-We individually ran the definitions and functions in Dr. Racket and of course there existed some ERRORS:(
-For myself, I did one mistake on step 6 and this is what I wrote in the first place
  (define (random-adjacent list-of-cells)
              (list-ref list-of-cells (random (length list-of-cells))))
 So, you see I did produce a random cell however I missed the part in the statement saying that the random chosen cell should be adjacent to the original cell. And because the mistake I made in step 6 will have further impact on step 9 and 10 I failed to run Part I.
-In the next day our team decided to meet at robarts library, after discussion with my team members I fixed my mistake. All my team members fixed their mistakes and so we arrived at the correct full answer for Part I. And then we worked on Part II together.

For Part II, we got a weird looking animation when we firstly run our codes.


After a lot discussion and analysis, we finally found why- The image sizes of tree and stone are NOT SAME as the size of the square! We fixed this problem and changed the colour of square--Balala we made it!

In this process each of us learnt to solve for the solution independently at the first place, and the communication helped us to find individual's mistakes therefore improved everyone's learning. We think the means of working in team of three is to firstly work individually and then never stop communication. We will use the same strategy for Project II and do our best!



Monday, 2 November 2015

Some advantages of using Dr. Racket over other programming languages

There are many programming languages such as BASIC, C, C++, COBOL, FORTRAN, etc. Each language is unique in its own way. In our course CSC104H1, we learn to use Dr. Racket and we should know the reason why we choose this rather than the other. 

Racket is important because it has unique features that can change the way you think about programming. The list of advantages are shown as following:
  • Racket enables the use of several different kinds of data including numbers, texts, lists, images, etc. It creates a new combination of using different datas and leads to a easier understanding of programming. 
  • Racket has advanced linguistic support for creating process-like abstractions within the language. What you had to go out to the operating system for, leading to less robustness and portability and much heavier weight, you can now do robustly, portably, and cheaply within the program. This again changes the way you architect systems.
  • Racket has delimited continuations. This gives you enormous power in creating control abstractions. This too changes the way you architect systems.
  • Racket has perhaps the most sophisticated yet practical contract system of any contemporary language. Building a cheap assertion system is trivial; anyone can do it in an afternoon. Building a rich contract system is very subtle and has taken a decade-and-a-half. Because this changes the kinds of statements you make about your program, this changes the way you think about describing your system.
  • Racket has a typed language, Typed Racket, which has a very powerful interoperation story with Racket (helping kick off the trend of “gradual typing”). This again changes the way you think about describing your system and splitting it into typed and untyped chunks.

So these are all things at which Racket is virtually unique, and their combination is even richer than the individual pieces. That's why Racket rewards study, and also enables the creation of very elegant and sophisticated systems with a good baseline of performance.