Question

I am trying to solve two point boundary problem with odeint. My equation has the form of

y'' + a*y' + b*y + c = 0

It is pretty trivial when I have boundary conditions of y(x_1) = y_1 , y'(x_2) = y_2, but when boundary conditions are y(x_1) = y_1 , y(x_2) = y_2 I am lost. Does anybody know the way to deal with problems like this with odeint or other scientific library?

Was it helpful?

Solution

In this case you need a shooting method. odeint does not have such a method, it solved the initial value problem (IVP) which is your first case. I think in the Numerical Recipies this method is explained and you can use Boost.Odeint to do the time stepping.

OTHER TIPS

An alternative and more efficient method to solve this type of problem is finite differences or finite elements method. For finite differences you can check Numerical Recipes. For finite elements I recommend dealii library.

Another approach is to use b-splines: Assuming you do know the initial x0 and final xfinal points of integration, then you can expand the solution y(x) in a b-spline basis, defined over (x0,xfinal), i.e.

y(x)= \sum_{i=1}^n A_i*B_i(x), 

where A_i are constant coefficients to be determined, and B_i(x) are b-spline basis (well defined polynomial functions, that can be differentiated numerically). For scientific applications you can find an implementation of b-splines in GSL.

With this substitution the boundary value problem is reduced to a linear problem, since (am using Einstein summation for repeated indices):

A_i*[ B_i''(x) + a*B_i'(x) + b*B_i(x)] + c =0

You can choose a set of points x and create a linear system from the above equation. You can find information for this type of method in the following review paper "Applications of B-splines in Atomic and Molecular Physics" - H Bachau, E Cormier, P Decleva, J E Hansen and F Martín

http://iopscience.iop.org/0034-4885/64/12/205/

I do not know of any library solving directly this problem, but there are several libraries for B-splines (I recommend GSL for your needs), that will allow you to form the linear system. See this stackoverflow question: Spline, B-Spline and NURBS C++ library

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top