Question: MATLAB Problem 6 ( 2 0 Points ) The Collatz Conjecture is an interesting one. Consider the following operation on an arbitrary positive integer from

MATLAB
Problem 6(20 Points)
The Collatz Conjecture is an interesting one. Consider the following operation on an arbitrary
positive integer from n to f(n) :
F(n)={3n+1,nisoddn2,niseven
That is, if the number is even, divide it by two; if the number is odd, triple it and add one. For
example, by applying this operation successively for a starting point n=3, we get:
3|10|5|16|8|4|2|1|4|2|1cdots
It was conjectured that, starting with any positive integer, this operation eventually ends up with
the periodic sequence 4|2|1. There is no proof yet!
a) Write a user-defined function "Collatz" which has n as input, and the following outputs:
A vector with all integers in the sequence.
The number of steps such that the number 1 first appears in the sequence.
The maximum integer that the sequence reached for a given value n.
b) For the set of integers in the interval 2,1000, write a code which calls the user-defined
function and produces the following (and show the outputs with appropriate details and labels):
A plot for the sequence corresponding to n=731.
A plot of n vs the sequence length.
A plot of n vs the maximum integer in its corresponding sequence.
A plot of n vs the average of consecutive differences of the sequence integers.
MATLAB Problem 6 ( 2 0 Points ) The Collatz

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!