% Linear Shooting with approach we saw in class 
% 11.1.3 a
fprintf('------------ 11.1.3 a -------------\n');
f = @(t,y,yp) -3*yp +2*y+2*t+3; 
a=0; b=1; alpha=2; beta=1; n=10; h=(b-a)/n;
y = linshoot(a,b,n,alpha,beta,f);
ytrue=@(x) -5*exp((1/2*(-3+sqrt(17)))*x)*(-1+exp(-3/2-(1/2)*sqrt(17)))/(exp(-3/2+(1/2)*sqrt(17))-exp(-3/2-(1/2)*sqrt(17)))+5*exp(-(1/2*(3+sqrt(17)))*x)*(-1+exp(-3/2+(1/2)*sqrt(17)))/(exp(-3/2+(1/2)*sqrt(17))-exp(-3/2-(1/2)*sqrt(17)))-3-x;
fprintf('%3s %11s %11s\n','t','y','y true');
for i=2:n+1,
 ti=a+(i-1)*h;
 fprintf('%3.1f %11.8f %11.8f\n',ti,y(i),ytrue(ti));
end;

% 11.1.3 b
fprintf('------------ 11.1.3 b -------------\n');
f = @(t,y,yp) (-4/t)*yp + (2/t^2)*y - (2/t^2)*log(t);
a=1;b=2; alpha=-1/2; beta=log(2); n=20; h=(b-a)/n;
y = linshoot(a,b,n,alpha,beta,f);
ytrue = @(x) x^(-3/2+(1/2)*sqrt(17))*(2^(1-(1/2)*sqrt(17))-3*sqrt(2))/(2^((1/2)*sqrt(17))-2^(-(1/2)*sqrt(17)))-x^(-3/2-(1/2)*sqrt(17))*(2^(1+(1/2)*sqrt(17))-3*sqrt(2))/(2^((1/2)*sqrt(17))-2^(-(1/2)*sqrt(17)))+log(x)+3/2;
fprintf('%4s %11s %11s\n','t','y','ytrue');
for i=1:n+1,
 ti=a+(i-1)*h;
 fprintf('%4.2f %11.8f %11.8f\n',ti,y(i),ytrue(ti));
end;
