
%nonlinear shooting method for y''=F(x,y,y')

1==1;

function z=vf(y,x)
 global FF
 z(1)=y(2);
 z(2)=FF(x,y(1),y(2)); 
 z=z';
endfunction

global FF

FF=@(x,y,dy) sin(y);


global ya yb a b
a=0;b=1;ya=1;yb=2;

function w=G(s)
  global ya yb a b
  X=lsode(@vf,[ya;s],[a,b]);
  w=X(2,1)-yb;
endfunction

s0=[G(-2),G(2)];
[s0,Gs0]=fzero(@G,[-2,2])
x=linspace(a,b,101);
X=lsode(@vf,[ya;s0],x);
plot(x,X(:,1))

s=linspace(-30,30,300);
for k=1:length(s),
  z(k)=G(s(k));
endfor
plot(s,z);
%repeat for F(x,y,,y')=y*y
FF=@(x,y,dy) y*y;
a=0;b=1;ya=1;yb=-4;

s=linspace(-30,1,300);
for k=1:length(s),
  z(k)=G(s(k));
endfor
plot(s,z);pause(1);

[s0,Gs0]=fzero(@G,[-10,10])
x=linspace(a,b,101);
X=lsode(@vf,[ya;s0],x);
plot(x,y=X(:,1));pause(1)
[s1,Gs1]=fzero(@G,[-30,-20])
x=linspace(a,b,101);
X=lsode(@vf,[ya;s1],x);
plot(x,y1=X(:,1),x,y)
