0% found this document useful (0 votes)
137 views24 pages

(Chapter 7) Solution To Examples in Chapter 3

This document summarizes the steps taken to solve three examples of boundary value problems using finite difference methods. 1) The first example solves a linear boundary value problem on a 1D grid using an inverse technique to solve the resulting system of equations. 2) The second example solves a nonlinear problem using Thomas algorithm to solve the tri-diagonal system that arises. 3) The third example solves a problem with Robin boundary conditions again using the finite difference approach.

Uploaded by

Bara Thi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views24 pages

(Chapter 7) Solution To Examples in Chapter 3

This document summarizes the steps taken to solve three examples of boundary value problems using finite difference methods. 1) The first example solves a linear boundary value problem on a 1D grid using an inverse technique to solve the resulting system of equations. 2) The second example solves a nonlinear problem using Thomas algorithm to solve the tri-diagonal system that arises. 3) The third example solves a problem with Robin boundary conditions again using the finite difference approach.

Uploaded by

Bara Thi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Chapter 7

Examples in Chapter 3

7.1 Example 3.1 (i) - Linear, Dirichlet BC


Use finite difference method to solve the following boundary value prob-
lem.
y 00 + xy 0 + y = x2,
y(0) = 0, y(1) = 1, and h = 0.25. (7.1)

Solution First of all, draw the following one-dimensional molecule


diagram to identify which values of y that need to be determined. Here
y(0) = y(x0) = y0 = 0 and y(1) = y(x4) = y4 = 1 are obtained from
the first and second boundary conditions respectively.
80 CHAPTER 7. EXAMPLES IN CHAPTER 3

From equation (7.1), we have


yi00 + xi yi0 + yi = x2i
   
yi−1 − 2yi + yi+1 yi+1 − yi−1
2
+ xi + yi = x2i
h 2h
2 (yi−1 − 2yi + yi+1 ) + hxi (yi+1 − yi−1 ) + 2h2 yi = 2h2 x2i

(2 − hxi ) yi−1 + −4 + 2h2 yi + (2 + hxi ) yi+1 = 2h2 x2i
(2 − 0.25xi ) yi−1 − 3.8750yi + (2 + 0.25xi ) yi+1 = 0.125x2i .
. . . . . . . . . (master equation)

Now, we start our calculation to find the solution of yi for i = 1, 2, 3


using the master equation.
For i = 1:
(2 − 0.25x1 ) y0 − 3.8750y1 + (2 + 0.25x1 ) y2 = 0.125x21
(1.9375) 0 − 3.8750y1 + (2.0625) y2 = 0.0078
−3.8750y1 + 2.0625y2 = 0.0078. (7.2)

For i = 2:
(2 − 0.25x2 ) y1 − 3.8750y2 + (2 + 0.25x2 ) y3 = 0.125x22
1.8750y1 − 3.8750y2 + 2.1250y3 = 0.0313. (7.3)

For i = 3:
(2 − 0.25x3 ) y2 − 3.8750y3 + (2 + 0.25x3 ) y4 = 0.125x23
(1.8125) y2 − 3.8750y3 + (2.1875) 1 = 0.0703
1.8125y2 − 3.8750y3 = −2.1172. (7.4)

Writing the linear equations (7.2), (7.3) and (7.4) into their system
of Ay = b, then we have
    
−3.8750 2.0625 0 y1 0.0078
 1.8750 −3.8750 2.1250   y2  =  0.0313  .
0 1.8125 −3.8750 y3 −2.1172
Basically we have several numerical techniques to solve the system such
as Doolittle, Cholesky, Gauss elimination and Thomas decomposition
7.1. EXAMPLE 3.1 (I) - LINEAR, DIRICHLET BC 81

methods. But since the matrix A is just of size 3 × 3 and there is no


specific method that we should use, so we may apply inverse technique
to solve the system.

Ay = b
−1
A (Ay) = A−1 (b)
y = A−1 b
 
0.3162
y = 0.5979 ♣
0.8261
82 CHAPTER 7. EXAMPLES IN CHAPTER 3

7.2 Example 3.4 (i) - Linear, Neumann


BC
Consider the nonlinear differential equation, Use finite difference method
to solve the following boundary value problem

y 00 = y + x,
y 0(0) = 1, y(1) = 2, h = 0.25. (7.5)

Solution As usual, your first move should be draw the following one-
dimensional molecule diagram to identify which values of y that need
to be found. Here y(1) = y(x4) = y4 = 2 is obtained from the second
boundary condition.

From equation (7.5), we have

yi00 = yi + xi
 
yi−1 − 2yi + yi+1
= yi + xi
h2
yi−1 − 2yi + yi+1 = h2 yi + h2 xi
yi−1 − 2yi + yi+1 − h2 yi = h2 xi

yi−1 + −2 − h2 yi + yi+1 = h2 xi
yi−1 − 2.0625yi + yi+1 = h2 xi . . . . . . (master equation)
7.2. EXAMPLE 3.4 (I) - LINEAR, NEUMANN BC 83

From the first boundary condition in equation (7.5), we obtain

y 0(0) = 1
y 0(x0 ) = 1
y00 = 1
 
y1 − y−1
=1
2h
y1 − y−1 = 2h
y−1 = y1 − 2h
y−1 = y1 − 0.5. (7.6)

Now, we start our calculation to find the solution of yi for i = 0, 1, 2, 3


using master equation.
For i = 0:
y−1 − 2.0625y0 + y1 = h2x0 . (7.7)
Substituting y−1 from equation (7.6) into equation (7.7), we retrieve

(y1 − 0.5) − 2.0625y0 + y1 = h2 x0


−2.0625y0 + 2y1 = 0.5. (7.8)

For i = 1:
y0 − 2.0625y1 + y2 = h2 x1
y0 − 2.0625y1 + y2 = 0.0156. (7.9)

For i = 2:
y1 − 2.0625y2 + y3 = h2 x2
y1 − 2.0625y2 + y3 = 0.0313. (7.10)

For i = 3:
y2 − 2.0625y3 + y4 = h2x3
y2 − 2.0625y3 + 2 = 0.0469
y2 − 2.0625y3 = −1.9531. (7.11)

Writing the linear equations (7.8), (7.9), (7.10) and (7.11) into their
84 CHAPTER 7. EXAMPLES IN CHAPTER 3

system of Ay = b, then we have


    
−2.0625 2 0 0 y0 0.5
 1 −2.0625 1 0   y1   0.0156 
=
  0.0313  .
  
 0 1 −2.0625 1   y2
0 0 1 −2.0625 y3 −1.9531

Basically we have several numerical techniques to solve the system but


since matrix A is a tri-diagonal matrix (also the size of 4×4 is difficult to
be computed using existing scientific calculator), so it is most suitable
if we may apply Thomas algorithm here. Recall the standard formula
for system of equation Ax = b for Thomas algorithm where we have
   
d1 e1 0 0 x1 b1
 c2 d2 e2 0   x2   b2 
=
  b3  .
  
 0 c3 d3 e3   x3
0 0 c4 d4 x4 b4

By comparing both systems, we may calculate to following values.

i 1 2 3 4(= n)
ci n/a 1 1 1
di -2.0625 -2.0625 -2.0625 -2.0625
ei 2 1 1 n/a
bi 0.5 0.0156 0.0313 -1.9531
α1 = d1 , -2.0625
αi = di − ci βi−1 , -1.0928 -1.1474 -1.1910
ei
βi = -0.9697 -0.9151 -0.8715 n/a
αi
b1
w1 = , -0.2424
α1
bi − ci wi−1
wi = -0.2361 -0.2330 1.4442
αi
x n = wn , 1.4442
xi = xi − βixi+1 0.4387 0.7024 1.0256
7.2. EXAMPLE 3.4 (I) - LINEAR, NEUMANN BC 85

Here (n/a) notation is refer to not available value. Since we are looking
solutions of y, hence we get
     
y0 x1 0.4387
 y1   x2   0.7024 
 y2  =  x3  =  1.0256  ♣
     

y3 x4 1.4442
86 CHAPTER 7. EXAMPLES IN CHAPTER 3

7.3 Example 3.5 (ii) - Linear, Robin BC


Use finite difference method to solve the following boundary value prob-
lem.

y 00 − y = 1,
1
y(0) − y 0 (0) = 1, y(1) + y 0(1) = 1, and h = 0.25. (7.12)
2

Solution First of all, draw the following one-dimensional molecule


diagram to identify which values of y that need to be determined.

From equation (7.12), we have

yi00 − yi =1
 
yi−1 − 2yi + yi+1
− yi =1
h2
yi−1 − 2yi + yi+1 − h2yi = h2

yi−1 − 2 + h2 yi + yi+1 = h2
yi−1 − 2.0625yi + yi+1 = 0.0625 . . . . . . (master equation)
7.3. EXAMPLE 3.5 (II) - LINEAR, ROBIN BC 87

From the first boundary condition in equation (7.12), we obtain


1
y(0) − y 0(0) = 1
2
1 0
y(x0) − y (x0 ) = 1
2
1
y0 − y00 = 1
 2
1 y1 − y−1
y0 − =1
2 2h
4hy0 − y1 + y−1 = 4h
y−1 = 4h − 4hy0 + y1
y−1 = 1 − y0 + y1 . (7.13)

From the second boundary condition in equation (7.12), we get

y(1) + y 0(1) = 1
y(x4) + y 0(x4 ) = 1
y4 + y40 = 1
 
y5 − y3
y4 + =1
2h
2hy4 + y5 − y3 = 2h
y5 = 2h − 2hy4 + y3
y5 = 0.5 − 0.5y4 + y3 . (7.14)

Now, we start our calculation to find the solution of yi for i = 0, 1, 2, 3, 4


using our master equation.
For i = 0:
y−1 − 2.0625y0 + y1 = 0.0625. (7.15)
Substituting y−1 from equation (7.13) into (7.15), we retrieve

(1 − y0 + y1 ) − 2.0625y0 + y1 = 0.0625
−3.0625y0 + 2y1 = −0.9375. (7.16)

For i = 1:
y0 − 2.0625y1 + y2 = 0.0625. (7.17)
88 CHAPTER 7. EXAMPLES IN CHAPTER 3

For i = 2:
y1 − 2.0625y2 + y3 = 0.0625. (7.18)

For i = 3:
y2 − 2.0625y3 + y4 = 0.0625. (7.19)

For i = 4:
y3 − 2.0625y4 + y5 = 0.0625. (7.20)

Substituting y5 from equation (7.14) into (7.20), we get

y3 − 2.0625y4 + (0.5 − 0.5y4 + y3) = 0.0625


2y3 − 2.5625y4 = −0.4375. (7.21)

Writing the linear equations (7.16), (7.17), (7.18), (7.19) and (7.21)
into their system of Ay = b, then we have
    
−3.0625 2 0 0 0 y0 −0.9375

 1 −2.0625 1 0 0 
 y1  
  0.0625 


 0 1 −2.0625 1 0 
 y2 =
  0.0625 .

 0 0 1 −2.0625 1  y3   0.0625 
0 0 0 2 −2.5625 y4 −0.4375

Once again as previous example it is most suitable if we may apply


Thomas algorithm here. Recall the standard formula for system of
equation Ax = b for Thomas algorithm where we have
    
d1 e1 0 0 0 x1 b1

 c2 d2 e2 0 0 
 x2  
  b2 


 0 c3 d3 e3 0 
 x3 =
  b3 .

 0 0 c4 d4 e4  x4   b4 
0 0 0 c5 d5 x5 b5

And comparing both systems leads us to get the following values.


7.3. EXAMPLE 3.5 (II) - LINEAR, ROBIN BC 89

i 1 2 3 4 5(= n)
ci n/a 1 1 1 2
di -3.0625 -2.0625 -2.0625 -2.0625 -2.5625
ei 2 1 1 1 n/a
bi -0.9375 0.0625 0.0625 0.0625 -0.4375
α1 = d1 , -3.0625
αi = di − ci βi−1 , -1.4094 -1.3530 -1.3234 -1.0513
ei
βi = -0.6531 -0.7095 -0.7391 -0.7556 n/a
αi
b1
w1 = , 0.3061
α1
bi − ci wi−1
wi = 0.1728 0.0815 0.0144 0.4435
αi
x n = wn , 0.4435
xi = xi − βi xi+1 0.5764 0.4139 0.3398 0.3495

Since we are looking solutions of y, hence we get


     
y0 x1 0.5764
 y1   x2   0.4139 
     
 y2  =  x3  =  0.3398
 ♣
   
 y3   x4   0.3495 
y4 x5 0.4435
90 CHAPTER 7. EXAMPLES IN CHAPTER 3

7.4 Example 3.7 - Nonlinear, Dirichlet BC


Consider the nonlinear differential equation,

y 00 + 2y 2 = 8x2 y 3, 0 ≤ x ≤ 1, (7.22)

with boundary conditions

y(0) = 1, y(1) = 0.5.

(i) Find the nonlinear system F(y) = 0 when we solve the problem
above using finite difference method with step size h = 0.25.

(ii) Solve the nonlinear system in part (i) using Newton’s method
with initial vector y(0) = 0 and apply stopping criteria ||y(k+1) −
y(k)||∞ < 0.005.

Solution

(i) As usual, your first move should be draw the following one-dimensional
molecule diagram to identify which values of y that we need to
be found.
7.4. EXAMPLE 3.7 - NONLINEAR, DIRICHLET BC 91

From equation (7.22), we have

yi00 + 2yi2 = 8x2i yi3


 
yi−1 − 2yi + yi+1
+ 2yi2 = 8x2i yi3
h2
yi−1 − 2yi + yi+1 + 2h2 yi2 − 8h2 x2i yi3 =0
yi−1 − 2yi + 2h2 yi2 − 8h2 x2i yi3 + yi+1 =0
yi−1 − 2yi + 0.125yi2 − 0.5x2i yi3 + yi+1 = 0 . . . (master equation)

Now, we start our calculation to find the solution of yi for i =


1, 2, 3 using our master equation.
For i = 1:

y0 − 2y1 + 0.125y12 − 0.5x21 y13 + y2 = 0


1 − 2y1 + 0.125y12 − 0.0313y13 + y2 = 0, (7.23)

where y0 = y(x0) = y(0) = 1 from the first boundary condition.


For i = 2:

y1 − 2y2 + 0.125y22 − 0.5x22y23 + y3 = 0


y1 − 2y2 + 0.125y22 − 0.125y23 + y3 = 0. (7.24)

For i = 3:

y2 − 2y3 + 0.125y32 − 0.5x23 y33 + y4 = 0


y2 − 2y3 + 0.125y32 − 0.2813y33 + 0.5 = 0, (7.25)

where y4 = y(x4) = y(1) = 0.5 from the second boundary condi-


tion.
Writing the nonlinear equations (7.23), (7.24) and (7.25) into their
system of F(y) = 0, then we have
   
1 − 2y1 + 0.125y12 − 0.0313y13 + y2 0
 y1 − 2y2 + 0.125y22 − 0.125y23 + y3  =  0  ,
y2 − 2y3 + 0.125y32 − 0.2813y33 + 0.5 0
92 CHAPTER 7. EXAMPLES IN CHAPTER 3

or denoted by
   
f1 (y1, y2, y3 ) 0
 f2 (y1, y2, y3 )  =  0  .
f3 (y1, y2, y3 ) 0

(ii) We want to solve nonlinear system of equations using Newton’s


method. So we have the formula of Newton as follows
 −1 
y(k+1) = y(k) − J y(k) F y(k) .

The Jacobian matrix is



J y(k)
 
∂f1 ∂f1 ∂f1
 ∂y1 ∂y2 ∂y3 
 
 ∂f2 ∂f2 ∂f2 
= 
 ∂y 1 ∂y 2 ∂y 3 

 ∂f3 ∂f3 ∂f3 
∂y1 ∂y2 ∂y3
 
−2 + 0.25y1 − 0.0938y12 1 0
 
= 1 −2 + 0.25y2 − 0.375y22 1 .

0 1 −2 + 0.25y3 − 0.8438y32
7.4. EXAMPLE 3.7 - NONLINEAR, DIRICHLET BC 93
 
k y(k) F y(k) J y(k)
     
0 1 −2 1 0
0 0 0  1 −2 1 
0 0.5 0 1 −2
     
0.8750 0.0747 −1.8531 1 0
1 0.7500   0.0176   1 −2.0234 1 
0.6250 −0.0198 0 1 −2.1734
     
0.9410 0.0003 −1.8487 1 0
2 0.7977  −0.0005  1 −2.0392 1 
0.6378 0 0 1 −2.1838

k y(k+1) ky(k+1) − y(k)k∞

  <
0.0050
= ε
0.8750 0.875

0 0.7500   0.75 

0.6250 0.625

  =
0.875 >ε
0.9410 0.066

1 0.7977  0.0477 

0.6378 0.0128

  =
0.066 > ε
0.9410
0

2 0.7974  −0.0003 

0.6377 −0.0001

= 0.0003 < ε (stop)

Therefore,    
y1 0.9410
y = y(3) = y2  = 0.7974  ♣
y3 0.6377
94 CHAPTER 7. EXAMPLES IN CHAPTER 3

7.5 Example 3.13 - Nonlinear, Neumann


BC
Consider the nonlinear differential equation,

2xy 00 + (y 0)2 − 4y = 4x, 1 ≤ x ≤ 2, (7.26)

with boundary conditions

y 0 (1) = 4, y 0(2) = 6.

(i) Find the nonlinear system F(y) = 0 when we solve the problem
above using finite difference method with step size h = 0.5.

(ii) Compute y(2) using Broyden’s method if initial vector y(0) =


(1, 1, 1)T .

Solution

(i) Firstly, draw the following one-dimensional molecule diagram in


order to identify which values of y that we need to calculate.
7.5. EXAMPLE 3.13 - NONLINEAR, NEUMANN BC 95

From equation (7.26), we have

2xi yi00 + (yi0 )2 − 4yi = 4xi


   2
yi−1 − 2yi + yi+1 yi+1 − yi−1
2xi + − 4yi = 4xi
h2 2h
8xi (yi−1 − 2yi + yi+1) + (yi+1 − yi−1 )2 − 16h2 yi − 16h2 xi = 0
8xi (yi−1 − 2yi + yi+1 ) + (yi+1 − yi−1 )2 − 4yi − 4xi = 0
. . . . . . . . . (master equation)

From the first boundary condition in equation (7.26), we obtain

y 0(1) = 4
y 0(x0) = 4
y00 = 4
 
y1 − y−1
=4
2h
y1 − y−1 = 4h
y−1 = y1 − 8h
y−1 = y1 − 4. (7.27)

From the second boundary condition in equation (7.26), we get

y 0(2) = 6
y 0(x2 ) = 6
y20 = 6
 
y3 − y1
=6
2h
y3 = 12h + y1
y3 = 6 + y1 . (7.28)

Now, we start our calculation to find the solution of yi for i =


0, 1, 2 using our master equation.
96 CHAPTER 7. EXAMPLES IN CHAPTER 3

For i = 0:
8x0 (y−1 − 2y0 + y1 ) + (y1 − y−1 )2 − 4y0 − 4x0 = 0. (7.29)
Substituting y−1 from equation (7.27) into (7.29), we retrieve
2
8x0 ((y1 − 4) − 2y0 + y1 ) + (y1 − (y1 − 4)) − 4y0 − 4x0 = 0
8(2y1 − 2y0 − 4) + 16 − 4y0 − 4 = 0
16y1 − 16y0 − 32 + 16 − 4y0 − 4 = 0
−20y0 + 16y1 − 20 = 0.
(7.30)
For i = 1:
8x1 (y0 − 2y1 + y2) + (y2 − y0)2 − 4y1 − 4x1 = 0
12y0 − 24y1 + 12y2 + (y2 − y0 )2 − 4y1 − 6 = 0
12y0 − 28y1 + 12y2 + (y2 − y0 )2 − 6 = 0. (7.31)

For i = 2:
8x2 (y1 − 2y2 + y3 ) + (y3 − y1 )2 − 4y2 − 4x2 = 0. (7.32)
Substituting y3 from equation (7.28) into (7.32), we get
8x2 (y1 − 2y2 + (6 + y1 )) + ((6 + y1 ) − y1)2 − 4y2 − 4x2 = 0
16 (2y1 − 2y2 + 6) + 36 − 4y2 − 8 = 0
32y1 − 36y2 + 124 = 0.
(7.33)
Writing the nonlinear equations (7.30), (7.31) and (7.33) into their
system of F(y) = 0, then we have
   
−20y0 + 16y1 − 20 0
 12y0 − 28y1 + 12y2 + (y2 − y0)2 − 6  =  0  ,
32y1 − 36y2 + 124 0
or denoted by
   
f1 (y0, y1, y2 ) 0
 f2 (y0, y1, y2 )  =  0  .
f3 (y0, y1, y2 ) 0
7.5. EXAMPLE 3.13 - NONLINEAR, NEUMANN BC 97

(ii) We want to solve nonlinear system of equations using Broyden’s


method up to y(2). So we have the formula of Broyden’s method
as follows 
y(k+1) ≈ y(k) − A−1
k F y
(k)
,
where  T −1
Sk − A−1
k−1 zk Sk Ak−1
A−1
k = A−1+
k−1 −1 ,
ST
k Ak−1 zk
 
zk = F y(k) − F y(k−1) ,
Sk = y(k) − y(k−1) ,
(0) −1
 
A−1
0 = J y .
If you take a look at the standard formula of Broyden’s method
as given in Chapter
 2, we need to find the solution x and use
(k)
yk = F x − F x(k−1) . For this example, we must change
 
both notations into solution y and use zk = F y(k) − F y(k−1)
respectively.
The Jacobian matrix is

J y(k)
 ∂f ∂f ∂f1 
1 1
 ∂y0 ∂y1 ∂y2 
 
 ∂f2 ∂f2 ∂f2 
= 

 ∂y0 ∂y1 ∂y2 

 ∂f3 ∂f3 ∂f3 
∂y0 ∂y1 ∂y2
 
−20 16 0
 
 12 − 2(y2 − y0) −28 12 + 2(y2 − y0 )  .
= 

0 32 −36
98 CHAPTER 7. EXAMPLES IN CHAPTER 3

 
k y(k) Sk F y(k) zk J y(k)
     
1 −24 −20 16 0
0 1 n/a −10 n/a  12 −28 12 
1 120 0 32 −36
       
1.4138 0.4138 −0.0008 23.9992
1 3.0172  2.0172  22.2094  32.2094 n/a
6.1264 5.1264 0 −120

−1
k ST
k Ak−1 zk A−1
k y(k+1)
   
−0.1121 −0.1034 −0.0345 1.4138
0 n/a −0.0776 −0.1293 −0.0431 3.0172 
−0.0690 −0.1149 −0.0661 6.1264
   
0.0075 0.0884 0.06 −0.5495
1 10.6904 0.0718 0.1104 0.075   0.5653 
0.0638 0.0982 0.0389 3.9455

Therefore,    
y0 −0.5495
y = y(2) = y1 =  0.5653  ♣
y2 3.9455
7.6. EXAMPLE 3.15 (I) - NONLINEAR, ROBIN BC 99

7.6 Example 3.15 (i) - Nonlinear, Robin


BC
For the following boundary value problems, find the system of nonlinear
equation F(y) = 0 if we approximate the solution using finite difference
method.
2y
y 00 + 4yy 0 + = 0, 0 ≤ x ≤ 1,
(1 + x2)
y(0) + y 0(0) = 1, y 0(1) = 0, h = 0.25. (7.34)

Solution Once again, do not forget to draw the following one-dimensional


molecule diagram in order to identify which values of y that we need
to find.

From equation (7.34), we have


2y
0 = y 00 + 4yy 0 +
(1 + x2 )
0 = (1 + x2 )y 00 + 4(1 + x2 )yy 0 + 2y
0 = (1 + x2i )yi00 + 4(1 + x2i )yiyi0 + 2yi
   
2 yi−1 − 2yi + yi+1 2 yi+1 − yi−1
0 = (1 + xi ) + 4(1 + xi )yi + 2yi
h2 2h
0 = 2(1 + x2i ) (yi−1 − 2yi + yi+1 ) + 4h(1 + x2i )yi (yi+1 − yi−1 ) + 4h2 yi
0 = 2(1 + x2i ) (yi−1 − 2yi + yi+1 ) + (1 + x2i )yi (yi+1 − yi−1 ) + 0.25yi
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (master equation)
100 CHAPTER 7. EXAMPLES IN CHAPTER 3

From the first boundary condition in equation (7.34), we obtain

y(0) + y 0(0) = 1
y(x0) + y 0(x0) = 1
y0 + y00 = 1
 
y1 − y−1
y0 + =1
2h
2hy0 + y1 − y−1 = 2h
y−1 = 2hy0 + y1 − 2h
y−1 = 0.5y0 + y1 − 0.5. (7.35)

From the second boundary condition in equation (7.34), we get

y 0(1) = 0
y 0(x4) = 0
y40 = 0
 
y5 − y3
=0
2h
y5 − y3 = 0
y5 = y3 . (7.36)

Now, we start our calculation to find the solution of yi for i = 0, 1, 2, 3, 4


using our master equation.
For i = 0:

2(1 + x20) (y−1 − 2y0 + y1 ) + (1 + x20)y0 (y1 − y−1 ) + 0.25y0 = 0. (7.37)

Substituting y−1 from equation (7.35) into (7.37), we retrieve

2 ((0.5y0 + y1 − 0.5) − 2y0 + y1 ) + y0 (y1 − (0.5y0 + y1 − 0.5)) + 0.25y0 = 0


2 (−1.5y0 + 2y1 − 0.5) + y0 (−0.5y0 + 0.5) + 0.25y0 = 0
−3y0 + 4y1 − 1 − 0.5y02 + 0.5y0 + 0.25y0 = 0
−2.25y0 − 0.5y02 + 4y1 − 1 = 0.
(7.38)
7.6. EXAMPLE 3.15 (I) - NONLINEAR, ROBIN BC 101

For i = 1:

2(1 + x21) (y0 − 2y1 + y2) + (1 + x21)y1 (y2 − y0 ) + 0.25y1 = 0


2.1250y0 − 4.25y1 + 2.1250y2 + 1.0625y1 y2 − 1.0625y0 y1 + 0.25y1 = 0
2.1250y0 − 1.0625y0 y1 − 4y1 + 1.0625y1 y2 + 2.1250y2 = 0.
(7.39)
For i = 2:

2(1 + x22) (y1 − 2y2 + y3) + (1 + x22)y2 (y3 − y1 ) + 0.25y2 = 0


2.5y1 − 5y2 + 2.5y3 + 1.25y2 y3 − 1.25y1 y2 + 0.25y2 = 0
2.5y1 − 1.25y1 y2 − 4.75y2 + 1.25y2 y3 + 2.5y3 = 0. (7.40)

For i = 3:

2(1 + x23 ) (y2 − 2y3 + y4 ) + (1 + x23 )y3 (y4 − y2) + 0.25y3 = 0


3.125y2 − 6.25y3 + 3.125y4 + 1.5625y3 y4 − 1.5625y2 y3 + 0.25y3 = 0
3.125y2 − 1.5625y2 y3 − 6y3 + 1.5625y3 y4 + 3.125y4 = 0.
(7.41)
For i = 4:

2(1 + x24) (y3 − 2y4 + y5) + (1 + x24)y4 (y5 − y3 ) + 0.25y4 = 0. (7.42)

Substituting y5 from equation (7.36) into (7.42), we get

2(1 + x24) (y3 − 2y4 + y3) + (1 + x24)y4 (y3 − y3 ) + 0.25y4 = 0


4(2y3 − 2y4 ) + 0.25y4 = 0
8y3 − 7.75y4 = 0. (7.43)

Writing the nonlinear equations (7.38), (7.39), (7.40), (7.41) and (7.43)
into their system of F(y) = 0, then we have
   
−2.25y0 − 0.5y02 + 4y1 − 1 0
 2.1250y0 − 1.0625y0 y1 − 4y1 + 1.0625y1 y2 + 2.1250y2   0 
   

 2.5y 1 − 1.25y 1 y 2 − 4.75y 2 + 1.25y 2 y 3 + 2.5y 3
 =  0 ♣
  
 3.125y2 − 1.5625y2 y3 − 6y3 + 1.5625y3 y4 + 3.125y4   0 
8y3 − 7.75y4 0
102 CHAPTER 7. EXAMPLES IN CHAPTER 3

You might also like