Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

10.13 Nonlinear BVP using finite difference method

Consider the BVP

y′′−2(y′)2y+y=0,x∈(−1,+1)y'' - 2 \frac{(y')^2}{y} + y = 0, \qquad x \in (-1,+1)

with boundary conditions

y(−1)=y(1)=1e+e−1y(-1) = y(1) = \frac{1}{e + e^{-1}}

The exact solution is given by

y(x)=1exp⁡(x)+exp⁡(−x)y(x) = \frac{1}{\exp(x) + \exp(-x)}

10.13.1Finite difference method

Make a uniform grid of n+1n+1 points such that

xj=−1+jh,0≤j≤n,h=2/nx_j = -1 + j h, \qquad 0 \le j \le n, \qquad h = 2/n

Then we approximate the differential equation by finite differences

ϕj=yj−1−2yj+yj+1h2−2yj(yj+1−yj−12h)2+yj=0,1≤j≤n−1\phi_j = \frac{y_{j-1}-2y_j + y_{j+1}}{h^2} - \frac{2}{y_j} \left(\frac{y_{j+1} - y_{j-1}}{2h}\right)^2 + y_j = 0, \quad 1 \le j \le n-1

with the boundary condition

y0=yn=1e+e−1y_0 = y_n = \frac{1}{e + e^{-1}}

This is a non-linear system of equations. We can eliminate y0,yny_0, y_n and form a problem to find the remaining unknowns. Define

Y=[y1,…,yn−1],ϕ=[ϕ1,…,ϕn−1]Y = [y_1, \ldots, y_{n-1}], \qquad \phi = [\phi_1, \ldots, \phi_{n-1}]

Then ϕ=ϕ(Y)\phi = \phi(Y) is a map from Rn−1R^{n-1} to Rn−1R^{n-1}. The Newton method is given by

ϕ′(Yk)δYk=−ϕ(Yk),Yk+1=Yk+δYk\phi'(Y^k) \delta Y^k = - \phi(Y^k), \qquad Y^{k+1} = Y^k + \delta Y^k

The Jacobian is given by

[ϕ′]jl=∂ϕj∂yl,1≤j,l≤n−1[\phi']_{jl} = \frac{\partial \phi_j}{\partial y_l}, \quad 1 \le j,l \le n-1

and it is a tri-diagonal matrix, since ϕj\phi_j depends only on yj−1,yj,yj+1y_{j-1}, y_j, y_{j+1}.

We now solve the problem with Newton method.

Number of iterations = 13
<Figure size 640x480 with 1 Axes>

Note that y is initially filled with boundary condition and then we update only the other values y[1:n] with Newton method. Thus during the Newton updates, y always satisfies the boundary condition.