function dglsys

[X,Y] = ode45(@(t,q) rhs(t,q),[0 2*pi], [0 1]);

plot(X,Y(:,1),X,sin(X))
xlabel('$x$','Interpreter','latex');
ylabel('Approx. $U_k$ und Lsg. $u(x)$','Interpreter','latex');
title('Numerische Approximation')
set(gcf,'paperpositionmode','auto')
legend({'Approx. $U_k$','Loesung $u(x)$'},'Interpreter','latex')
set(gca,'xlim',[0 2*pi],'ylim',[-1 1],'fontsize',17)
print('-depsc','-loose','dglsyslsg');

plot(X,Y(:,1)-sin(X))
xlabel('$x$','Interpreter','latex');
ylabel('Fehler $U_k-u(x_k)$','Interpreter','latex');
title('Approximationsfehler')
set(gcf,'paperpositionmode','auto')
set(gca,'xlim',[0 2*pi],'ylim',[-2.E-4 2.E-4],'fontsize',17)
print('-depsc','-loose','dglsyserr');

function dq = rhs(t,q)
dq = q;
dq(1) = q(2);
dq(2) = -q(1);
