3
// PROBLEM 1: LINEAR DIFFERENTIAL/ALGEBRAIC SYSTEM
7
//X1(0) = 1.0, X2(0) = 0.0
9
t=1:10;t0=0;y0=[1;0];y0d=[-10;0];
10
info=list([],0,[],[],[],0,0);
11
// with default atol and rtol parameters
12
// Calling Scilab functions
13
deff('[r,ires]=dres1(t,y,ydot)','r=[ydot(1,:)+10*y(1,:);y(2,:)+y(1,:)-1];ires=0')
14
deff('pd=djac1(t,y,ydot,cj)','pd=[cj+10,0;1,1]')
15
// scilab function, without jacobian
16
yy0=dassl([y0,y0d],t0,t,dres1,info);
17
if norm(dres1(yy0(1,:),yy0(2:3,:),yy0(4:5,:)),1)>1.d-6 then pause,end
18
// scilab functions, with jacobian
19
yy1=dassl([y0,y0d],t0,t,dres1,djac1,info);
20
if norm(dres1(yy1(1,:),yy1(2:3,:),yy1(4:5,:)),1)>1.d-6 then pause,end
21
// fortran routine dres1 in dir. routines/default, without jocabian
22
yy2=dassl([y0,y0d],t0,t,'dres1',info); //=yy0
23
if norm(dres1(yy2(1,:),yy2(2:3,:),yy2(4:5,:)),1)>1.4d-6 then pause,end
24
// fortran routines dres1 and djac1 in dir. routines/default, with jacobian
25
yy3=dassl([y0,y0d],t0,t,'dres1','djac1',info); //=yy1
26
if norm(dres1(yy3(1,:),yy3(2:3,:),yy3(4:5,:)),1)>1.d-6 then pause,end
27
//if norm(yy3-yy1,1) > Eps then pause,end
28
yy3bis=dassl([y0,y0d],t0,t,'dres1',djac1,info);
29
if norm(dres1(yy3bis(1,:),yy3bis(2:3,:),yy3bis(4:5,:)),1)>1.d-6 then pause,end
30
// call fortran dres1 and scilab's djac1
31
yy3ter=dassl([y0,y0d],t0,t,dres1,'djac1',info);
32
if norm(dres1(yy3ter(1,:),yy3ter(2:3,:),yy3ter(4:5,:)),1)>1.d-6 then pause,end
34
// with specific atol and rtol parameters
36
// scilab function, without jacobian
37
yy4=dassl([y0,y0d],t0,t,atol,rtol,dres1,info);
38
if norm(dres1(yy4(1,:),yy4(2:3,:),yy4(4:5,:)),1)>1.d-5 then pause,end
39
// fortran routine dres1 in dir. routines/default, without jocabian
40
yy5=dassl([y0,y0d],t0,t,atol,rtol,'dres1',info); //=yy4
41
if norm(dres1(yy5(1,:),yy5(2:3,:),yy5(4:5,:)),1)>1.d-5 then pause,end
43
yy6=dassl([y0,y0d],t0,t,atol,rtol,dres1,djac1,info);
44
if norm(dres1(yy6(1,:),yy6(2:3,:),yy6(4:5,:)),1)>1.d-5 then pause,end
46
yy7=dassl([y0,y0d],t0,t,atol,rtol,'dres1','djac1',info); //==yy6
47
if norm(dres1(yy7(1,:),yy7(2:3,:),yy7(4:5,:)),1)>1.d-5 then pause,end