function magFac = tacoma6(inter,ic,h,p,W)
format long
a=inter(1);b=inter(2);n=ceil((b-a)/(h*p));% plot n points
y_of_t = [];
y=[];
y(1,:)=ic;
t=[];
t(1)=a;
for k=1:n
    for i=1:p
    t(i+1) = t(i)+h;
    y(i+1,:) = rk4step(t(i),y(i,:),h,W);
    end
y(1,:) = y(p+1,:);t(1)=t(p+1);
y_of_t = [y_of_t; y(1,1),y(1,3)];
end
magFac=100 - max(abs(y_of_t(:,2)))/abs(ic(1,3))

function y=rk4step(t,w,h,W)
%one step of the Runge-Kutta order 4 method
s1=ydot(t,w,W);
s2=ydot(t+h/2,w+h*s1/2,W);
s3=ydot(t+h/2,w+h*s2/2,W);
s4=ydot(t+h,w+h*s3,W);
y=w+h*(s1+2*s2+2*s3+s4)/6;

function ydot=ydot(t,y,W)
len=6; a=0.2; omega=2*pi*38/60;
a1=exp(a*(y(1)-len*sin(y(3))));
a2=exp(a*(y(1)+len*sin(y(3))));
ydot(1) = y(2);
ydot(2) = -0.01*y(2)-0.4*(a1+a2-2)/a+0.2*W*sin(omega*t);
ydot(3) = y(4);
ydot(4) = -0.01*y(4)+1.2*cos(y(3))*(a1-a2)/(len*a);