% Antti Hannukainen 1.3.2006
%
%
% Solve BVP :
%
% x' = f(t,x)
% 
% g(x(h(1)),x(h(lenght(h))) = 0
% 
%
% with midpoint rule
% 
% x = bvp_solve(f,g,x0,N)
%
% 
% f  = f(t,x) = function handle to function f
%
% g  = g(x(a),x(b)) = function hadle to funcition g
%
% x0 = initial guess
%
% h  = mesh in time
% 
%
% Return : x = solution
% 
%
% The solution is done with the empedding :
%


function x = bvp_solve(f, g, x0, t)

% Solve

u = bvp_x2u(x0);
u = gnewton(u,@(u)(bvp_fu(u,f,g,t)),@(u)(bvp_Dfu(u,f,g,t)),@lufun);
x = bvp_u2x(u,N);