% despejando de ecuaciones finitas
clear all
clc
close all

deltat=0.0001;
m=100000;
x1=zeros(m,1);
x2=zeros(m,1);
n=1;
x1(1)=1;
x2(1)=0;

while n<=m-1
    x1(n+1)=x2(n).*deltat+x1(n);
    x2(n+1)=-x1(n).*deltat+x2(n);
    n=n+1;
end

#figure(1)
#plot(x1)
#grid on

figure(1, "visible", "off");
plot(x1);
grid;
print -deps "../media/coseno.eps";

figure(2, "visible", "off");
plot(x2);
grid;
print -deps "../media/seno.eps";


figure(3, "visible", "off");
plot(x1,x2);
grid;
print -deps "../media/x1_et_x2.eps";




deltat=0.001;
x1=zeros(m,1);
x2=zeros(m,1);
n=1;
x1(1)=1;
x2(1)=0;

while n<=m-1
    x1(n+1)=x2(n).*deltat+x1(n);
    x2(n+1)=-x1(n).*deltat+x2(n);
    n=n+1;
end



figure(1, "visible", "off");
plot(x1);
grid;
print -deps "../media/coseno_deltat001.eps";

figure(2, "visible", "off");
plot(x2);
grid;
print -deps "../media/seno_deltat001.eps";


figure(3, "visible", "off");
plot(x1,x2);
grid;
print -deps "../media/x1_et_x2_deltat001.eps";








deltat=0.01;
x1=zeros(m,1);
x2=zeros(m,1);
n=1;
x1(1)=1;
x2(1)=0;

while n<=m-1
    x1(n+1)=x2(n).*deltat+x1(n);
    x2(n+1)=-x1(n).*deltat+x2(n);
    n=n+1;
end



figure(1, "visible", "off");
plot(x1);
grid;
print -deps "../media/coseno_deltat01.eps";

figure(2, "visible", "off");
plot(x2);
grid;
print -deps "../media/seno_deltat01.eps";


figure(3, "visible", "off");
plot(x1,x2);
grid;
print -deps "../media/x1_et_x2_deltat01.eps";
