Solving Numerically a second order ODE

78 Views Asked by At

I have a second order ordinary differential equation to solve: The equation is as follows: $a(x)P'(x)+b(x)P''(x)=0$, where $x \in [0,\infty)$ and $P$ is a probability distribution.

When $0 \leq x \leq 10$, $a(x)= 3-2x$ and $b(x) = \dfrac{3-2x}{\ln(1.5x)}$.

When $x\geq 10$, the coefficients are constants, $a(x)=-27$ and $b(x)=\dfrac{-27}{\ln(20)}$.

So I split up my ODE as follows:

$(3-2x)P_{1}'(x)+\dfrac{2-3x}{\ln(1.5x)}P_{1}''(x)=0$ for $0\leq x\leq 10$,

and

$-27P_{2}'(x)-\dfrac{27}{\ln(20)}P_{1}''(x)=0$ for $10\leq x< \infty$.

I have the following conditions:

$P_1(10)=P_2(10)$.

$P_1'(10)=P_2'(10)$

$$\int_0^{10}P_1(x)\,dx + \int_{10}^{\infty}P_2(x)\,dx=1$$

and

$\displaystyle\lim_{x\to\infty }P_2(x)=0$.

$P$ is a probability distribution and in this case I can replace $\infty$ by large number, say, $1000,$ and that should be fine. I.e., $P_2(1000)=0.$

I don't know how to initialize my numerical scheme since I do not have an explicit expression for the boundary condition at $x=0$.

1

There are 1 best solutions below

3
On

Start with the solution in the region $10 \leq x < \infty$, in that region the solution is fairly simple to get

$$ P_2(x) = \alpha + \beta ~ 20^{-x} \tag{1} $$

And you can get the value of one of the constants by forcing the solution to go to zero at infinity

$$ \lim_{x\to \infty} P(x) = \lim_{x\to \infty} P_2(x) = 0 = \alpha \tag{2} $$

So the solution so far for this region is

$$ P_2(x;\beta) = \beta ~ 20^{-x} $$

So the idea is to find a solution for $P_1$ that smoothly connects with $P_2$ at $x=10$. A possible way is to define a function

\begin{eqnarray} f(\beta) &=& \int_{0}^{+\infty}P(x) {\rm d}x - 1 = \int_{0}^{10}P_1(x) {\rm d}x + \int_{10}^{+\infty}P_2(x) {\rm d}x- 1 \\ &=& \int_{0}^{10}P_1(x) {\rm d}x + \frac{\beta}{20^{10}\ln 20} - 1 \end{eqnarray}

and find the solution of the problem $f(\beta) = 0$.

For each value of $\beta$ you find the value of $P_2(x)$ and use that as boundary conditions for the numerical integration of $P_1$. Of all possible values of $\beta$ you choose the one that normalizes the probability