I've been given a second-order non-linear ODE:

$$\frac{d^{2}\theta(s)}{ds^{2}} = sf_{g}\cos{\theta} + sf_{x}\cos{\phi}\sin{\theta}$$

where $f_{g}, f_{x}$ and $\phi$ are constants.

The boundary conditions for $[0,L]$ are:

  • $\frac{d\theta}{ds}\Big|_{s=0} = 0 $

  • $\theta (L) = \theta_L$

I will be repeating this numerous times for different values of $L$, implementing the solution method as a function. The $\theta_L$ is just a constant assumed known each time.

I am unsure how to proceed with these boundary conditions (are they Neumann, Dirichlet etc.? I don't think so). I struggle when I try to convert the BVP into an IVP for the shooting method and I've read the documentation for bvp4c and ode45 over and over with no progress on this problem. I just can't seem to get started here.

Could anyone give me some pointers or help? Thank you very much in advance.

  • $\begingroup$ You have boundary conditions at both ends of the region (0 and L) so you have a boundary value problem as opposed to an initial value problem where there would be boundary conditions at only one end of the domain. The bvp4c function works well for this class of problem. Where did you get stuck trying to use bvp4c? $\endgroup$ Dec 9, 2015 at 17:06

1 Answer 1


To start you could change it into a system of first-order ODEs $$Y(s) := \left( \begin{split} \theta'(s)\\ \theta(s) \end{split} \right) = \left(\begin{split} Y_1(s)\\ Y_2(s) \end{split} \right)\,,$$ $$ Y'(s) = \left( \begin{split} s f_g \cos(Y_2(s)) + s f_x \cos \phi\sin(Y_2(s))\\ Y_1(s) \end{split} \right)\,.$$

$$Y(0) = \left(\begin{align} 0\\ t \end{align}\right)\,.$$ Then the shooting method, parametrised by $t$ as initial conditions, that means use different values of $t$ as an initial condition. Approximate value of $t$ can be find in the style taught in this lecture. The easiest root finding method is the bisection method. For that you should know a range in which the value of $t$ lies $[t_a t_b]$. Substitute $t_a$, $t_b$ and $t_c$ (mid point of $t_a$ and $t_b$), as three different I.C and solve that using ode45 then check weather you are getting closer to $Y_2(L)=\theta_L$, then reduce the search range in bisection algorithm algorithm until you get desired accuracy.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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