# Initializing BVP

**URL:** <https://discourse.julialang.org/t/initializing-bvp/87598>\
**Category:** General Usage\
**Created:** [September 21, 2022, 6:57pm UTC](https://discourse.julialang.org/t/initializing-bvp/87598 "2022-09-21T18:57:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jojo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jojo/32/42799_2.png) [@Jojo](https://discourse.julialang.org/u/Jojo)\
**Post date:** [September 21, 2022, 6:57pm UTC](https://discourse.julialang.org/t/initializing-bvp/87598/1 "2022-09-21T18:57:50Z")

</div>

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

```julia
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)
```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 21, 2022, 8:53pm UTC](https://discourse.julialang.org/t/initializing-bvp/87598/2 "2022-09-21T20:53:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jojo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jojo/32/42799_2.png) [@Jojo](https://discourse.julialang.org/u/Jojo)\
**Post date:** [September 21, 2022, 9:06pm UTC](https://discourse.julialang.org/t/initializing-bvp/87598/3 "2022-09-21T21:06:26Z")

</div>

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
