# solving Boundary-value problem ODE in matlab numerically

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.

-
QIang Li, I have a problem similar to yours. Could you solve it? Or with other software different from Matlab? Thank you, Damian. – user14475 Aug 11 '11 at 13:11
@Damian: I have converted your answer to a comment. Because you do not have 50 reputation points yet, you can only comment on your own questions and answers. So, you didn't do anything wrong; the "add comment" button will only appear for you once you gain 50 points. Here is an explanation of reputation points. – Zev Chonoles Aug 11 '11 at 13:16

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.
you meant $F_2(K) = KF'(K)$? This will not work! seems that you made a mistake somewhere... – Qiang Li Mar 19 '11 at 16:18
Yes, I meant $F_2(K) = KF'(K)$ and I made a mistake. Sorry about that. I edited my answer to correct this. – Jitse Niesen Mar 21 '11 at 11:41
the problem is that: the first terms is still $$\frac{3.45}{0.02K^2} F_2$$ instead of $$\frac{3.45}{0.02K} F_2$$. – Qiang Li Mar 21 '11 at 14:45