#octave script testing 1D linear MES

0==1;



#u=sin(x) a=0, b=pi 
s=@sin; #solution -u''=u=sin(t)
f=@sin;
a=0;b=1;
al=s(a);be=s(b);
N0=20;
x=x0=linspace(a,b,N0);

M=5;
c=0;



#equidistant mesh
disp("tests on equidistant mesh on [0,1]  u=sin(t)");
[h,ner,ratio,rner,rratio]=testMESDbc(f,s,x,c,M=5);
[h',ner,rner]
[ratio,rratio]


#sinusoidal mesh

disp("tests on sinusoidal  mesh on [0,1]  u=sin(t) i.e. x_k=a+(b-a)sin(k/N)/sin(1)");
x=a+(b-a)*sin(linspace(0,1,N0))/sin(1);
[h,ner,ratio,rner,rratio]=testMESDbc(f,s,x,c,M=5);
[h',ner,rner]
[ratio,rratio]


#funkcja kwadratowa
disp("tests on equidistant mesh on [0,1]  u(t)=t^2");
s=@(x) 0.5.*x.*x;
f=@(x) -1.0;
x=x0;
[h,ner,ratio,rner,rratio]=testMESDbc(f,s,x,c,5);
[h',ner,rner]
[ratio,rratio]

disp("blad zaokraglen tylko... w pkt siatki\n");

#funkcja szescienna
disp("tests on equidistant mesh on [0,1]  u(t)=t^3");
c=0;
s=@(x)  x.*x.*x;
f=@(x) -6.0*x+c.*s(x);
x=x0;
[h,ner,ratio,rner,rratio]=testMESDbc(f,s,x,c,5);
[h',ner,rner]
[ratio,rratio]

disp("blad zaokraglen tylko na siatce...\n");

#f st 4
disp("-u''+c=f tests on equidistant mesh on [0,1]  u(t)=t^4");
c=1;
s=@(x)  x.*x.*x.*x;
f=@(x) -12.0*x.*x+c.*s(x);
x=x0;
[h,ner,ratio,rner,rratio]=testMESDbc(f,s,x,c,5);
[h',ner,rner]
[ratio,rratio]






