[t,x]=odeEuler(f,[t0,tf],x0,h);
fprintf('dif = %.6f\n',dif)
opcions=odeset('AbsTol',1e-8,'RelTol',1e-8);
[t,x]=ode45(f,[t0,tf],x0,opcions);
fprintf('xf = %.6f\n',xf)
opcions=odeset('AbsTol',1e-8,'RelTol',1e-8);
F=@(t,X) [P(X(1),X(2));Q(X(1),X(2))];
[t,X]=ode45(F,[t0,tf],X0,opcions);
fprintf('quocient = %.6f\n',quocient)
opcions=odeset('AbsTol',1e-8,'RelTol',1e-8);
R=@(t,x,y,z) z-2*y+5*x+sin(t);
F=@(t,X) [P(t,X(1),X(2),X(3));Q(t,X(1),X(2),X(3));R(t,X(1),X(2),X(3))];
[t,X]=ode45(F,[t0,tf],X0,opcions);
x=X(:,1); y=X(:,2); z=X(:,3);
suma=x(end)+y(end)+z(end);
fprintf('suma = %.6f\n',suma)
opcions=odeset('AbsTol',1e-8,'RelTol',1e-8);
F=@(t,X) [P(X(1),X(2));Q(X(1),X(2))];
X0=[0.2,0.1; 0.1,0.2; 0.7,0; 0,0.7];
%hem anat provant diferents valors de tf fins que amb tf=12
%ja visualitzem que les 4 solucions son periodiques
[t,X]=ode45(F,[t0,tf],X0(i,:),opcions);
fprintf('tf = %.2f\n',tf)
opcions=odeset('AbsTol',1e-8,'RelTol',1e-8);
P=@(t,x,y) t.*sin(x.^2)-y;
F=@(t,X) [P(t,X(1),X(2));Q(t,X(1),X(2))];
[t,X]=ode45(F,[t0,tf],X0,opcions);
dist=sqrt(X(end,1)^2+X(end,2)^2);
fprintf('dist = %.6f\n',dist)