recur1.m      monster1.m      monster2.m      monster3.m      monster4.m
%-----------------------------------------
%script recur
%compute the dominant and subdominant 
%solutions of a recurrence
clear
figure
m = 60
%ascending
x(1)=(1-sqrt(5))/2;
for i=2:m
   x(i)=1+1/x(i-1);
end
for k = 1:4
   subplot(2,2,k);
   plot(1:(15*k),x(1:15*k)-x(1))
end
%descending
x(1)=(1+sqrt(5))/2;
for i=2:m
   x(i)=1/(x(i-1)-1);
end
for k = 1:4
   subplot(2,2,k);
   plot(1:(15*k),x(1:15*k)-x(1))
end


%-----------------------------------------
%script monster1
% plots the function T(x) = e^x ln(1+e^-x)
% For x>30 a dramatic deviation from the 
% Theoretical value is found; for x>36.7,
% the value drops spuriously to 0
x = linspace(33.5,37,333331);
y = exp(x).*log(1+exp(-x));
z = log(1+exp(-x))*10^(15)/3.5*2;
plot(x,y,x,z)
title('plot of f1=log(1+e^-1) with f2 = e^x*f1 ')
%-----------------------------------------
%script monster2
% plots the function T(x) = e^x ln(1+e^-x)
% For x>30 a dramatic deviation from the 
% Theoretical value is found; for x>36.7,
% the value drops spuriously to 0
x = linspace(50,55,333331);
y = 2.^(x).*log(1+2.^(-x));
z = 2.^(x).*log(1-2.^(-x));
plot(x,y,x,z)
title('plot of f1=2^xlog(1+2^-x), f2 = 2^xlog(1-2^-x)')
%-----------------------------------------
%script monster3
% plots the function T(x) = (sqrt(x(i)+9)-3)/x(i)
% For x>30 a dramatic deviation from the 
% Theoretical value is found; for x>36.7,
% the value drops spuriously to 0
x = linspace(-0.00000000000003,0.00000000000003,333331);
%y = (x.^2-2*x+1)-(x-1).^2;
for i = 1:333331,
   y(i)= (sqrt(x(i)+9)-3)/x(i);
end
plot(x,y)
title('plot of T(x) = (sqrt(x(i)+9)-3)/x(i) ')
%-----------------------------------------
%script monster4
% plots the function T(x) = (x^2-2x+1)-(x-1)^2
% in various orders of evaluation: y and w identical
x = linspace(-0.000000000000001,0.000000000000001,333331);
%y = (x.^2-2*x+1)-(x-1).^2;
%for i = 1:333331,
   %y(i)= (sqrt(x(i)+9)-3)/x(i);
   y = (1-2*x + x.^2)-(1-x).^2;
   z = (x-1).^2-(x.^2 - 2*x + 1);
   w = (x.^2 - 2*x + 1)-(x-1).^2;
%end
plot(x,y,x,.66*z,x,.33*w)
title('plots of T(x) = (x^2-2x+1)-(x-1)^2 ')
