How to deal with this differential equation with boundary values?

In my research I have come across the following problem that I am trying to solve numerically.

I have

$$\frac{d}{dr} \left[ \frac{1}{r^2 \rho(r)} \left( \frac{d \psi(r)}{dr} \right) \right] + \frac{4\pi G \rho(r)}{r^2 P(r)} \psi(r) = \frac{d}{dr} \left( \frac{F(r)}{r^2 \rho(r)} \right)$$

with $\psi(r=r_\min) = \psi(r=r_\max) = 0$.

I have numeric values for all of those variables except for $\psi$ which I would like to solve for numerically.

I am looking to use scipy's solve_bvp but it requires the problem to be stated as a system of first order ODEs. How can I solve this problem?

• One can always recast a second order problem $y''=f(t,y,y')$ as $x'=y,y'=f(t,x,y)$.
– Ian
Nov 11 '16 at 19:17
• @Ian can you show me? Nov 11 '16 at 19:19
• So you have 3 unknowns and 1 ODE, Right? Nov 11 '16 at 19:21
• There is not much to show. Rewrite your equation as $\psi''=f(r,\psi,\psi')$, then you can rewrite your equation as $\psi'=y,y'=f(t,\psi,y)$.
– Ian
Nov 11 '16 at 19:21
• @Narasimham My understanding is that $\rho,P,G$ and $F$ are all given.
– Ian
Nov 11 '16 at 19:21

Set $$\varphi(r)=\frac{1}{r^2 \rho(r)} \left( \frac{d \psi(r)}{dr} \right) - \frac{F(r)}{r^2 \rho(r)} \\~\\ \iff\\~\\ \frac{d \psi(r)}{dr} = r^2 \rho(r)\varphi(r) + F(r)$$ so that the original equation reduces to first order $$\frac{dφ(r)}{dr}=-\frac{4\pi G \rho(r)}{r^2 P(r)} \psi(r)$$ Together both equations constitute an equivalent first order system.