# Non linear BVP using Second order finite difference method.

I was solving the following non-linear BVP by second order finite difference method.

The BVP is $y'' + 3yy'=0$ with boundary conditions $y(0) = 2$ and $y(2)=1$.

While looking at the solution it has used the following scheme-

$$y = \frac{y_{i+1}+y_{i-1}}{2}$$ $$y' = \frac{y_{i+1}-y_{i-1}}{2h}$$ $$y'' = \frac{y_{i+1}-2y_{i}+y_{i-1}}{h^2}$$

and solved the BVP using Newton's method which I got it. But I am thinking that why it has assumed the first condition in such a way,I guess that it has to do something with second order finite difference but how do i relate this?

The second expression $y'$ is similar to the central difference and also $y''$ is similar to the formula for second order derivatives.

EDIT:-

Now if there is an $x$ term,what should I replace $x$ with ? like i did for $y,y',y''$? like for example $y'' + 3xyy' = 0$ then $x$ must be substituted with? as I did for $y,y',y''$?

How do I relate these assumptions to second order finite difference method?

• I don't think you need the first approximation, it doesn't help you at all. With an $x$ term, don't do anything, just evaluate at the appropriate grid points. – David Sep 20 '17 at 23:29
• Ok,perhaps it will be ok if i use $y = y_{i}$ and if there is an $x$ term then $x = x_{i}$, but how the other two expressions of $y'$ and $y''$ are related to statement second order finite difference method?.@David , the expession of $y''$ is $O(h^2)$ and I think order of $y'$ is $O(h)$ – BAYMAX Sep 21 '17 at 0:54

In practice, a second-order differential equation is recast into a first-order system. By setting $Y=(y_1,u_2)^\top$ where $y_1 = y$ and $y_2=y'$, we have $$Y' = (y_2, -3 y_1 y_2)^\top = F(Y) \, ,$$ which an autonomous first-order ODE system. An initial value problem of the type $Y(x_0) = Y_0$ can be solved numerically using for instance Runge-Kutta methods. In the second case, $$Y' = (y_2, -3 x y_1 y_2)^\top = F(x,Y)$$ is non-autonomous, and Runge-Kutta methods still apply. The resolution of a boundary value problem with such conditions as $y(x_0) = y_0$ and $y(x_1) = y_1$ can be achieved using the shooting method.
• If you see,while dealing with ODE we apply central difference scheme but while dealing with PDE we usually apply forward difference scheme?Why is that so?,the above question is actually asking to relate the derivative and $O(h^k)$,like if $y$ is 6th order differentiable then why error term is of order $O(h^{4})$ – BAYMAX Sep 21 '17 at 13:52
The first term probably results from approximating and factorizing by the binomial formula, $$yy'=\frac12(y^2)'\approx \frac{y_{i+1}^2-y_{i-1}^2}{4h}=\frac{y_{i+1}+y_{i-1}}2·\frac{y_{i+1}-y_{i-1}}{2h}$$ Identifying backwards equates $y'$ with the central difference quotient and thus $y$ with the mean.
• I have haeard that if say $y$ is 6 times differentiable then error associated while applying the scheme is $O(h^{4})$,why is that so? – BAYMAX Sep 21 '17 at 14:09
• I do not know. Individually the approximations are all $O(h^2)$. Because of symmetry the error terms are functions of $h^2$, so one would have to show that the combined second order coefficient is zero. – LutzL Sep 21 '17 at 14:39