# Initializing BVP

Hello, I’m new to the BoundaryValueDiffEq package and I’ve seen some examples of its use for solving second order differential equations. However, I was wondering whether it’s posible to solve first order BVPs too.

I tried to initialize the following system but the solver throws retcode: failure

\frac{du}{dx}=\sqrt{(1+a-cos(u))(1+cos(u/b)}, u(-L)=4\pi,u(L)=4\pi

function ode!(du,u,p,t)
du[1] = sqrt((1 + p[1] - cos(u[1])) * (1 + cos(u[1] / p[2])))
end

function bc2!(residual, u, p, t)
residual[1] = u[1][1] +p[2]*pi
residual[2] = u[end][1]-p[2]*pi
end
tspan=(-50,50)
bvp2 = TwoPointBVProblem(ode!, bc2!,[-4*pi,4*pi] ,tspan,[0.1,4])
sol2 = solve(bvp2, MIRK4(), dt=0.5)

You can’t in general solve a first-order ODE with two boundary conditions — for first order, you only get one boundary condition.

2 Likes

Equations of that type are really common when considering static solitons which are fields with two different fixed values at the boundaries. However, the first order ode comes from an energy conservation constraint. Maybe I should just try to solve the second order parent ode. Thanks