
%solving u''=u^2 u(0)=1 u(1)=-4 
%by shooting method (using lsode and fsolve)

0==0;
global vf alpha beta a b

a=0;b=1;
alpha=1;beta=-4;

vf=@(x,t) [x(2);x(1)*x(1)];

function y=F(s)
global vf alpha beta a b

X=lsode(vf,[alpha;s],[a,b]);
y=beta-X(2,1);
end

s1=fsolve(@F,-6)
F(s1)


s2=fsolve(@F,-30)
F(s2)

t=linspace(a,b);
X1=lsode(vf,[alpha;s1],t);
X2=lsode(vf,[alpha;s2],t);

plot(t,X1(:,1),[";s1=",num2str(s1),";"],t,X2(:,1),[";s2=",num2str(s2),";"]);

