h = 0.2;
rtol = odeset('RelTol',1e-5);
for alfa = -0.2:0.1:0.5
    [X,U] = ode45(@fcurl,[0 12],[0 alfa]',rtol);
    plot(X,U(:,1))
    hold on
    axis equal
    yslut = U(end,1);
    disp([alfa yslut])
end


%%
alfa1 = 0.2;
alfa2 = 0.3;
rtol = odeset('RelTol',1e-5);
[X,U] = ode45(@fcurl,[0 12],[0 alfa1]',rtol);
g1 = U(end,1)-4;
h = 0.1;
iter = 0;
TOL = 0.5e-6;
while abs(h/alfa2)>TOL & iter < 10
    [X,U] = ode45(@fcurl,[0 12],[0 alfa2]',rtol);
    g2 = U(end,1)-4
    gp = (g2-g1)/(alfa2-alfa1);
    h = -g2/gp;
    alfa1 = alfa2;
    g1 = g2;
    alfa2 = alfa2 + h;
    iter = iter + 1;
end
alfa = alfa2;
iter
plot(X,U(:,1),'--')
hold off
