# bvp4c or ode45? [closed]

I am solving two the first order ODEs ($'=\dfrac{d}{dz}$, all other variables are known constants):

$$p_0 p_0'=-\dfrac{32 \beta}{R^4}$$

$$(p_0p_1)'=-\dfrac{2-\sigma_v}{\sigma_v}\dfrac{8}{R}p_0'$$

I have next conditions

$p_0|_{z=0}=p_{0i}$ (I can choose value)

$p_0|_{z=1}=1$

$p_1|_{z=0}=0$

$p_1|_{z=1}=0$

It is necessary to find $p_0'|_{z=0}$ and $p_1'|_{z=0}$ with shooting method (literature says like that), according to already mentioned $p_0|_{z=1}=1$ and $p_1|_{z=1}=0$. How to connect this two conditions and shoot $p_0'|_{z=0}$ for already known $p_0|_{z=1}=1$?

Are that conditions $p_0'|_{z=0}$ and $p_1'|_{z=0}$ necessary, because these are the first order equations, is there only one initial condition enough?

Instead of missing conditions, I also need to solve numerically two ODEs, from the beginning of text, with Runge Kutta method. How to connect that solving with shooting? Is it possible to find missing condition with bvp4c, as shooting method, and after that solve equation with ode45?

## closed as unclear what you're asking by Yves Daoust, user284331, José Carlos Santos, Matthew Towers, user223391 May 6 '18 at 16:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Yes, for a boundary value problem you better use a BVP solver. For an order 1 system in 2 components you can only ever hope to satisfy 2 arbitrary boundary conditions, thus if you chose to fix values to $p_0(0)$ and $p_0(1)$, the values of $p_1$ are dependents, there is no guarantee that they will be even close to zero. However, as the equation for $p_0$ is independent of $p_1$, you can always only fix one boundary condition for $p_0$, the other has to be for $p_1$ and you could solve the problem in 2 stages, first find the other boundary value of $p_0$ and then solve the coupled problem from the side where the condition for $p_1$ is given.

• But how to solve equation with Runge Kutta, I need to do that also? – nick_name May 3 '18 at 11:05
• It does not matter if you use a one-step or a multi-step solver, as long as you stay in the "nice" area of the domain of the ODE. A BVP solver is a shooting method that employs an ODE solver and makes many calls to the ODE solver, esp. for multiple shooting. Is there somewhere a more complete version of your task, as the present version is not really solvable as you intend. – LutzL May 3 '18 at 11:39
• You can not possibly satisfy all 4 boundary conditions. In the answer to a different question I wrote that the first equation has solution $p_0(z)^2=p_0(0)^2-\frac{64\beta}{R^4}z$ which will have a singularity in the integration interval if $|p_0(0)|\le \frac{8\sqrt\beta}{R^2}$. – LutzL May 3 '18 at 11:51
• Yes, you can still solve for $p_0$ directly, I wrote an answer to an earlier question of yours where this was given. – LutzL May 3 '18 at 12:07
• Two boundary conditions require an ODE of order 2 or more. At some point you made an error, an over-simplification in your computation. Or some constants are design parameters that can also be varied to satisfy the boundary conditions. – LutzL May 3 '18 at 12:10

The first equation integrates as

$$p_0^2=az+c$$

and the second as

$$p_0p_1=bp_0+d$$ where $c,d$ are the integration constants.

Why would you need a numerical integrator ? And by the way, you can only specify two conditions.

• My case ih that $R$ is dependent on $z$, as $p_0$ and $p_1$, so relation is $R=r-z*(r-1)$, where $r$ is constant. Also $p_0'=\dfrac{dp_0}{dz}$. How to integrate equations in this case? – nick_name May 3 '18 at 14:00
• @nick_name You said "all other variables are known constants". Are we deemed to guess $R(z)$ ??? And you didn't even notice that I used $p'_0=\dfrac{dp_0}{dz}$. – Yves Daoust May 3 '18 at 14:03
• Well, just in one subcase they are, sorry. But solution is necessary for every global case. – nick_name May 3 '18 at 14:06
• @nick_name: solving with $R=az+b$ is also straightforward. – Yves Daoust May 3 '18 at 14:09