I've got a second order nonlinear ODE (nothing fancy), but the BC are a little odd to me:

  • $y'(0) = 0$
  • $y \rightarrow y_a$ as $x \rightarrow \infty$

What's a good numerical method for solving this? Thinking of MATLAB, but I'm open to libraries in C/C++ if there are any.



A common introductory way to solve a BVP like this is the Shooting Method. As you may know, solving the problem:

$y''(t) = f(t,y,y')$ with $y(x_0) = y_0$ and $y'(x_0) = y'_0$

is fairly straight forward using a technique such as Euler's method or any variety of RK methods. What time-stepping algorithm you choose depends on your problem's stiffness and stability.

You don't have exactly this problem however. The shooting method involves solving the above equation over and over with varying $y_0$ until your $y_\infty$ approaches $y_a$. This can be done by wrapping a root-finding method around your time-stepping algorithm.

Your problem also has the added complication of the right BC being defined in the far field, rather than some point. You obviously can't advance your solution out to infinity, so you must choose some arbitrary right boundary $x_{large}$ and solve it twice with the BC's:

$y(x_{large}) = y_a$ and $y(2 x_{large}) = y_a$

If your two solutions agree, then you know $x_{large}$ was choosen big enough that it was like having the boundary at $\infty$. If not, you must resolve it with an even higher boundary.

  • $\begingroup$ Thanks, this is actually what I thought about myself. This is what I will try first. $\endgroup$ – Urban Jan 31 '13 at 17:46

From what little I know about it, the boundary element method (BEM) can handle asymptotic boundary conditions. It seems to be popular for acoustics and electromagnetics problems due to its simple handling of asymptotic boundary conditions. For a 1D problem it may work out especially well.

  • $\begingroup$ Thank you for your suggestion about BEM. I know too little about BEM and I guess this would be an opportunity to investigate it further. $\endgroup$ – Urban Jan 31 '13 at 17:47

Godric's solution is a good one, but sometimes there's a better way of doing the shooting method for asymptotic boundary conditions.

Basically the idea is to approximate the ODE with another ODE which captures the behavior of the original in the large $x$ limit. For example, terms like

$$\left(x-\alpha\right)\frac{d \phi}{dx}$$ or $$\frac{\beta}{x^2}\phi $$

would become $$x\frac{d \phi}{dx}$$ and $$0$$

If the resulting differential equation is exactly solvable, you can pick the exact solution that has the asymptotic behavior you require and some $x$ large enough that the asymptotic approximation is good, and then use the shooting method to find the matching point.

Something like this technique also works for oscillatory asymptotic boundary conditions.

If you find yourself doing these kinds of problems a lot, you might want to check out Bender and Orszag's eldrich tome of asymptotics lore.

  • $\begingroup$ I haven't seen this idea before and I'm not sure it will be applicable in my case, but I thank you for the suggestion. $\endgroup$ – Urban Jan 31 '13 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.