## Description

- Explain what the following Matlab code does

- x= -10:10;

- x= 0:0.01:1;

- x= 10:-1:-10;

2. | Find the function value of y = 3x^{2} using 101 equally spaced points in [ 1; 1]. Plot the all the isolated |
||

points in x y plane using the \plot” command. Be sure to give your graph a title, label the x and | |||

y axis, and display a legend. You only need to submit your graph. | |||

3. | Write a Matlab code using for loop to de ne the following sequence. | ||

2x_{n} |
1; if x_{n} > 1=2: |
||

x_{0} = 1=3; x_{n+1} = |
2x_{n}; |
if x_{n} 1=2; |

- The golden ratio shows up in many places in the nature. This ratio gets its name from the golden rectangle shown below. This rectangle has the property that removing a square leaves a smaller rectangle of the same proportions as the original.

Taking the ratio of corresponding sides gives | 1 | = | 1 | . Rearranging, we have the quadratic equation | |||

1 | |||||||

^{2}1=0. |
|||||||

- Find the two roots of this quadratic by hand. The positive root is the golden ratio.

- Find its zeros via the \fzero” command.

- The Fibonacci Sequence is de ned recursively as

f_{n} = f_{n} _{1} + f_{n} _{2}; f_{1} = 1; f_{2} = 2:

(a) Write a Matlab function f = fibonacci(n) which returns a vector containing the rst n terms of Fibonacci numbers.

(b) Estimate the term-by-term growth rate of the Fibonacci sequence. To do this, compute the rst

40 Fibonacci numbers via the function in part (a), then compute ratios n = ^{f}^{n+1} . What does ^{f}n

the value of _{n} seem to approach? Explain your thought on the connection between the Fibonacci sequence and the golden ratio.

1

(c) Consider the matrices

1 1

^{A =}

1 0

- Computer A
^{n}for n =1:5, or more if necessary. Compare yournding with the Fibonacci number. Explain why.

- Use Matlab to compute the eigenvalues of matrix A. What is the result? How is your nding connected to the Fibonacci sequence thus the golden ratio?

- In Matlab construct the following sequence.

Start with a random positive integer If a_{n} = 1, terminate;

If a_{n} is even a_{n+1} = a_{n}=2 If a_{n} is odd a_{n+1} = 3a_{n} + 1

- Write a Matlab function y = threenplus1(n) returning a vector y which is the entire sequence generated by positive integer n. (Hint: Use a while loop and if statements.)

- Write a Matlab script to compute the sequences generated by integers 2 through 10. Plot them all in the same graph.

- The 3n + 1 sequence has a particular shape for n starting at 5; 10; 20; 40; 80; : : : Why?

- The graphs of 3n + 1 sequences are all quite similar for n = 108; 109; 110. Why?

- (Challenge) Does the sequence always terminate? Can you nd a value of a
_{1}such that the sequence has in nitely many terms? (That is, the sequence never terminates.)

- (Challenge) Consider organizing the positive integers in an n n array in a spiral fashion as illustrated in the below picture. Note the prime numbers are highlighted in red. The location of these primes forms what is called an Ulam prime spiral. By plotting points, this spiral is hilighted in the next image for the 200 200 case. Write a Matlab script which replicates the second image. Generate your own image for the 400 400 and 800 800 cases. For more on Ulam prime spirals, see
__http:____//blogs.mathworks.com/cleve/2015/01/05/prime-spiral/__.

2