% Lab 10 Esercizio pag 9 da tema esame
clc
clear all
close all
% dati del problema
f=@(t,y)y.^2.*(cos(t)-t);
t0=0;
tmax=5;
y0=1/3;
% *******************************************
sol=@(t)-1./(sin(t)-t.^2/2-3);
% ***************************************
% punto 1
dfy=@(t,y)2*y.*(cos(t)-t);
[T,EI]=eulimp(f,[t0:0.005:tmax],y0,dfy,1e-6,200);
[T,CN]=cranknic(f,[t0:0.005:tmax],y0,dfy,1e-6,200);
Yesa=sol(T);
format short e
ErrEi=norm(Yesa-EI)
ErrCN=norm(Yesa-CN)
I_EI=trapz(T,EI)
I_CN=trapz(T,CN)
format short