% ODE solver

clear
clf

tspan=[0 7];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[1 0];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[sqrt(2)/2 sqrt(2)/2];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

axis equal

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[0 1];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[-sqrt(2)/2 sqrt(2)/2];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[-1 0];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[-sqrt(2)/2 -sqrt(2)/2];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[0 -1];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y0=[sqrt(2)/2 -sqrt(2)/2];
[T,Y]=ode45(@g,tspan,y0);

% plots
figure(1)
plot(Y(1,1),Y(1,2),'*')
hold on
plot(Y(:,1),Y(:,2))


