Question 8.3: FINITE-DIFFERENCE METHOD, LINEAR BVP Consider the BVP in Exa...
FINITE-DIFFERENCE METHOD, LINEAR BVP
Consider the BVP in Example 8.1:
\ddot{u} =0.02u+1, u(0)=10, u(10)=100Solve by the finite-difference method using central-difference formulas and h = Δt = 2.
Learn more on how do we answer questions.
At each interior grid point, the second derivative is replaced with a central difference formula to obtain
\frac{u_{i-1}-2u_{i} +u_{i+1} }{\Delta t^{2} }=0.02u_i+1Since the length of the interval is 10 and Δt = 2, we have N = 10/2 = 5, so that there are N − 1 = 4 interior points. Simplifying the above equation, we find
u_{i-1} -(2+0.02\Delta t^{2} ) u_{i}+u_{i+1} =\Delta t^{2}, i=2,3,4,5 (8.4)
Note that u_1 = 10 and u_6 = 100 are available from the boundary conditions. Applying Equation 8.4 yields
As projected by the structure of Equation 8.4, the resulting coefficient matrix is tridiagonal, and thus will be solved using the Thomas method (Section 4.3). That yields
u_2 = 15.0489 , u_3 = 25.3018 , u_4 = 41.5788 , u_5 = 65.1821Comparison with the Shooting Method
In Example 8.1, we learned that the true solution (using the shooting method) of the current BVP is obtained by solving the following system via RK4:
TABLE 8.1 | |||
Comparison of Results: Shooting Method, Finite Difference, Actual (Example 8.3) |
|||
t | Finite Difference | Shooting Method | Actual |
0 | 10 | 10 | 10 |
2 | 15.0489 | 15.2760 | 15.2762 |
4 | 25.3018 | 25.8084 | 25.8093 |
6 | 41.5788 | 42.4455 | 42.4478 |
8 | 65.1821 | 66.5269 | 66.5315 |
10 | 100 | 100 | 100 |
In order to compare the numerical results generated by the shooting method with those given above by the finite-difference method, the step size in shooting method (RK4) must be adjusted to 2:
>> t = 0:2:10;
>> f = @(t,x)([x(2);0.02*x(1)+1]);
>> x0 = [10;yi];
% Solutions by the shooting method at interior grid points
>> u = RK4System(f,t,x0); u(1,[2:end-1])
ans =
15.2760 25.8084 42.4455 66.5269
The exact values at the interior grid points are readily found as follows:
>> ue = matlabFunction(dsolve('D2u = 0.02*u+1','u(0)=10, u(10)=100'));
% Exact solutions at interior grid points
>> ue(t(2:end-1))
ans =
15.2762 25.8093 42.4478 66.5315
A summary of the preceding calculations is presented in Table 8.1, where it is immediately observed that the shooting method produces much more accurate estimates than the finite-difference method. The main reason for this is that the shooting method relies on the RK4 method, which enjoys a very high level of accuracy. The accuracy of both techniques can be improved by reducing the step size Δt.