% Iterator.m
% This script prints out an orbit of F
%
% Inputs (these can be modified):
% F is the map to be iterated
% n is the number of times to iterate F
% x0 is the initial point in the orbit
% Outputs:
% the orbit of F with initial point x0 (printed in the console)
% this is a list of values of length n+1
% they are x0, F(x0), F^2(x0), ..., F^n(x0)
F = @(x) cos(x);
n = 20;
x0 = 22;
%%%%%%%%%%%%%%%%%%%%%
% Main code (does not need to be modified)
%%%%%%%%%%%%%%%%%%%%%
orbit = zeros(1,n+1);
orbit(1) = x0;
for i = 1:n
orbit(i+1) = F(orbit(i));
end
% Print out the orbit
orbit