metode=3; %1=eksplisitt euler, 2=symplektisk euler, 3=implisitt euler
antall_runder=10;
n=antall_runder*1000;
h=antall_runder*2*pi/n;

y=zeros(n,1);
z=zeros(n,1);

y(1)=1;
z(1)=0;

%eksplisitt euler
if metode==1
    for i=1:n-1
        y(i+1)=y(i)+h*z(i);
        z(i+1)=z(i)+h*sin(y(i));
    end
end

%symplektisk euler
if metode==2
    for i=1:n-1
        y(i+1)=y(i)+h*z(i);
        z(i+1)=z(i)+h*sin(y(i+1));
    end
end


%implisitt euler
if metode==3
    for i=1:n-1
        y(i+1)=y(i);
        z(i+1)=y(i);
        v=[100,100];
        while norm([v(1)-y(i+1),v(2)-z(i+1)]) > .0001
            v=[y(i+1),z(i+1)];
            y(i+1)=y(i)+h*z(i+1);
            z(i+1)=z(i)+h*sin(y(i+1));
        end
    end
end


plot(y,z);
