[Math] solving Boundary-value problem ODE in matlab numerically

MATLABnumerical methods

I am using matlab to solve the following ODE

$$0.02K^2 F''(K)-3.45 F'(K)-3.45=0.08 F(K) $$

subject to boundary conditions

$$F(K=0)=63.09$$ and $$ F(K=700)=0.$$

I found that I had to give bvpinit an offset such as
bvpinit(linspace(1e-3,700,10000),[1 0.1])
from the left boundary 0 because otherwise, I would get an error

Error using ==> bvp4c
Unable to solve the collocation equations -- a singular Jacobian encountered

But this isn't really elegant, because the offset seems arbitary. This also did not extend the solution all the way to the left end point 0. Would appreciate if someone can provide a better solution to this problem. Many thanks.

Best Answer

This is called a singular boundary-value problem. Matlab can handle some singular BVPs (look at the documentation for bvp4c and the SingularTerm option in bvpset) so you need to bring your equation in the form that Matlab can handle.

Added later: I've never used this option before, but here is how I would start. When bringing the equation to first-order form, one normally introduces a vector $(F_1,F_2)$ with $F_1(K) = F(K)$ and $F_2(K) = F'(K)$ so that the equation becomes $$ \begin{align} F_1' &= F_2, \\ F_2' &= \frac{3.45}{0.02K^2} F_2 + \frac{0.08}{0.02K^2} F_1 + \frac{3.45}{0.02K^2}. \end{align} $$ As you noticed, Matlab requires the equation to be of the form $y' = \frac1x Sy + f(x,y)$ ...

Added yet later: I initially thought that one could get rid of the $1/K^2$ terms by using $F_1(K) = F(K)$ and $F_2(K) = KF'(K)$ but as Qiang Li noted (in more polite terms) I made a stupid mistake. In fact, in the original equation the boundary point $K=0$ is an irregular singular point, while in the equations that Matlab can handle the boundary point is a regular singular point. My uneducated guess would be that the algorithm implemented in Matlab won't be able to handle your equation. Sorry.

Related Question