Exercise 2.1
Exercise 2.3
Exercise 3.1
Once we finished the car function, the next step was to insert a loop into it that would allow us to calculate the amount of cars at each location after a certain number of weeks (in this case it was 52). In order to create a loop, we enclosed our original function in a "for" command, setting the number of times the loop should run (i) to 52. While not shown in the image below, we found that the number of cars exchanged between Boston and Albany reached equilibrium when there was 118 cars in Albany and 182 cars in Boston.
Exercise 3.2
When we got the graph above, we realized that we had switched our x and y axis. The corrected graph is shown below. One thing to note is that as the initial number of cans increases, the graph lines get smoother.
Exercise 3.5
In this exercise we returned to the fibonacci sequence, this time aiming to use a recurrent equation to compute the first ten numbers. To do this, we used a loop function that would allow us to add the previous sequence value computed to help produce the next one. For the below code, we ended up printing 12 sequence numbers rather than 10 because we didn't account of our code which dictated that we go to the "i + 2th" term. We should have either said "i= 1:8" so that it would print the first ten numbers or we could have written "Print F(i-2)" to solve the problem. Either way, we achieved the goal of the exercise.
Exercise 4.6
The last exercise was to write a script that computes a vector for the "n+1th" term of the fibonacci sequence divided by the nth term, and then plot this vector to determine where it converges. From the plot, we determines that the values converged around 1.6.
No comments:
Post a Comment