0% found this document useful (0 votes)
142 views

Boundary Value Problem Numec

The document discusses numerical methods for solving boundary value problems (BVPs). It describes two types of BVPs - ones with boundary conditions without derivatives, and ones with boundary conditions that include an initial derivative. For both cases, it shows how to derive finite difference equations to discretize and solve the BVPs by dividing the domain into a grid, applying central differencing approximations to the derivatives, and setting up a linear system of equations that can be solved for the unknown values at each grid point. An example problem is worked out in detail to demonstrate the process.

Uploaded by

shakiru
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)
142 views

Boundary Value Problem Numec

The document discusses numerical methods for solving boundary value problems (BVPs). It describes two types of BVPs - ones with boundary conditions without derivatives, and ones with boundary conditions that include an initial derivative. For both cases, it shows how to derive finite difference equations to discretize and solve the BVPs by dividing the domain into a grid, applying central differencing approximations to the derivatives, and setting up a linear system of equations that can be solved for the unknown values at each grid point. An example problem is worked out in detail to demonstrate the process.

Uploaded by

shakiru
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/ 17

CECB423 Numerical Methods for Civil Engineers

Boundary Value Problem (BVP)

a) Boundary condition without derivative

Consider the general linear two point BVP,

𝑦 ′′ (𝑥) + 𝑝(𝑥)𝑦 ′ (𝑥) + 𝑞(𝑥)𝑦(𝑥) = 𝑟(𝑥); 𝑎≤𝑥≤𝑏

With the boundary condition (without derivative)

𝑦(𝑎) = 𝛼 and 𝑦(𝑏) = 𝛽

To derive the finite-difference equation, the interval [a,b] is divided by step size h,

First boundary condition at Second boundary condition at


𝑥=𝛼 𝑥=𝑏
𝑦(𝑎) = 𝛼 𝑦(𝑏) = 𝛽
𝑦(𝑥0 ) = 𝛼 𝑦(𝑥𝑛 ) = 𝛽
𝑦0 = 𝛼 𝑦𝑛 = 𝛽

At grid points 𝑥 = 𝑥𝑖 , the differential equation can be written as

𝑦 ′′ (𝑥𝑖 ) + 𝑝(𝑥𝑖 )𝑦 ′ (𝑥𝑖 ) + 𝑞(𝑥𝑖 )𝑦(𝑥𝑖 ) = 𝑟(𝑥𝑖 )

By using central differentiation


𝑦𝑖+1 − 𝑦𝑖−1
𝑦 ′ (𝑥𝑖 ) ≈
2ℎ
𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1
𝑦 ′′ (𝑥𝑖 ) ≈
ℎ2
Substituting the approximation into above equation,

𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 𝑦𝑖+1 − 𝑦𝑖−1


[ 2 ] + 𝑝𝑖 [ ] + 𝑞𝑖 𝑦𝑖 = 𝑟𝑖
ℎ 2ℎ
CECB423 Numerical Methods for Civil Engineers

And multiplying throughout by h2



𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 + 𝑝𝑖 (𝑦𝑖+1 − 𝑦𝑖−1 ) + ℎ2 𝑞𝑖 𝑦𝑖 = ℎ2 𝑟𝑖
2

Rearrange the equation,

ℎ ℎ
(1 − 𝑝𝑖 )𝑦𝑖−1 + (−2 + ℎ2 𝑞𝑖 )𝑦𝑖 + (1 + 𝑝𝑖 )𝑦𝑖+1 = ℎ2 𝑟𝑖
2 2

Expanding the finite difference equation for 𝑖 = 1,2,3, … . , 𝑛


i.e:

at i=1 ℎ ℎ
(1 − 𝑝1 )𝑦0 + (−2 + ℎ2 𝑞1 )𝑦1 + (1 + 𝑝1 )𝑦2 = ℎ2 𝑟1
2 2

at i=2 ℎ ℎ
(1 − 𝑝2 )𝑦1 + (−2 + ℎ2 𝑞2 )𝑦2 + (1 + 𝑝2 )𝑦3 = ℎ2 𝑟2
2 2

at i=3 ℎ ℎ
(1 − 𝑝3 )𝑦2 + (−2 + ℎ2 𝑞3 )𝑦3 + (1 + 𝑝3 )𝑦4 = ℎ2 𝑟3
2 2

Combine all equation in linear system of from 𝐴𝑦 = 𝑏

Solve the value of 𝑦1 , 𝑦2 , 𝑦3 , … … … . , 𝑦𝑛

Example:

Solve the BVP


1 1
𝑦 ′′ + 𝑦 ′ + 2 𝑦(𝑥𝑖 ) = 3; 𝑦(1) = 2, 𝑦(2) = 3
𝑥 𝑥

For x at interval [1,2] with h=0.2. Use four decimal places in all calculation.
CECB423 Numerical Methods for Civil Engineers

1 1
𝑦 ′′ + 𝑦 ′ + 2 𝑦(𝑥𝑖 ) = 3
𝑥 𝑥
𝑦 ′′ (𝑥) + 𝑝(𝑥)𝑦 ′ (𝑥) + 𝑞(𝑥)𝑦(𝑥) = 𝑟(𝑥)

First boundary condition at Second boundary condition at


𝑦(1) = 2 𝑦(2) = 3
𝑦(𝑥0 ) = 2 𝑦(𝑥5 ) = 3
𝑦0 = 2 𝑦5 = 3

ℎ ℎ
(1 − 𝑝𝑖 )𝑦𝑖−1 + (−2 + ℎ2 𝑞𝑖 )𝑦𝑖 + (1 + 𝑝𝑖 )𝑦𝑖+1 = ℎ2 𝑟𝑖
2 2

at i=1 0.2 1 1 0.2 1


[1 − ( ∗ )] 𝑦0 + [−2 + (0.22 ∗ 2 )] 𝑦1 + [1 + ( ∗ )] 𝑦2 = (0.2)2 ∗ 3
(x1=1.2) 2 𝑥 𝑥 2 𝑥
(y0=2)
0.2 1 1 0.2 1
[1 − ( ∗ )] (2) + [−2 + (0.22 ∗ )] 𝑦1 + [1 + ( ∗ )] 𝑦2 = (0.2)2 ∗ 3
2 1.2 1.22 2 1.2

1.8333 − 2.0278𝑦1 + 1.0833𝑦2 = 0.12

−𝟐. 𝟎𝟐𝟕𝟖𝒚𝟏 + 𝟏. 𝟎𝟖𝟑𝟑𝒚𝟐 = −𝟏. 𝟕𝟏𝟑𝟑

at i=2 0.2 1 1 0.2 1


[1 − ( ∗ )] 𝑦1 + [−2 + (0.22 ∗ 2 )] 𝑦2 + [1 + ( ∗ )] 𝑦3 = (0.2)2 ∗ 3
(x2=1.4) 2 𝑥 𝑥 2 𝑥

0.2 1 1 0.2 1
[1 − ( ∗ )] 𝑦1 + [−2 + (0.22 ∗ )] 𝑦2 + [1 + ( ∗ )] 𝑦3 = (0.2)2 ∗ 3
2 1.4 1.42 2 1.4

𝟎. 𝟗𝟐𝟖𝟔𝒚𝟏 − 𝟐. 𝟎𝟐𝟎𝟒𝒚𝟐 + 𝟏. 𝟎𝟕𝟏𝟒𝒚𝟑 = 𝟎. 𝟏𝟐

at i=3 0.2 1 1 0.2 1


[1 − ( ∗ )] 𝑦2 + [−2 + (0.22 ∗ 2 )] 𝑦3 + [1 + ( ∗ )] 𝑦4 = (0.2)2 ∗ 3
(x3=1.6) 2 𝑥 𝑥 2 𝑥

0.2 1 1 0.2 1
[1 − ( ∗ )] 𝑦2 + [−2 + (0.22 ∗ 2
)] 𝑦3 + [1 + ( ∗ )] 𝑦4 = (0.2)2 ∗ 3
2 1.6 1.6 2 1.6

𝟎. 𝟗𝟑𝟕𝟓𝒚𝟐 − 𝟐. 𝟎𝟏𝟓𝟔𝒚𝟑 + 𝟏. 𝟎𝟔𝟐𝟓𝒚𝟒 = 𝟎. 𝟏𝟐

at i=4 0.2 1 1 0.2 1


[1 − ( ∗ )] 𝑦3 + [−2 + (0.22 ∗ 2 )] 𝑦4 + [1 + ( ∗ )] 𝑦5 = (0.2)2 ∗ 3
(x4=1.8) 2 𝑥 𝑥 2 𝑥
(y5=3)
0.2 1 1 0.2 1
[1 − ( ∗ )] 𝑦3 + [−2 + (0.22 ∗ 2
)] 𝑦4 + [1 + ( ∗ )] (3) = (0.2)2 ∗ 3
2 1.8 1.8 2 1.8

0.9444𝑦3 − 2.0123𝑦4 + 3.1668 = 0.12

𝟎. 𝟗𝟒𝟒𝟒𝒚𝟑 − 𝟐. 𝟎𝟏𝟐𝟑𝒚𝟒 = −𝟑. 𝟎𝟒𝟔𝟖


CECB423 Numerical Methods for Civil Engineers

Solve the system using trigonal system

−2.0278 1.0833 0 0 𝑦1 −1.7133


0.9286 −2.0204 1.0714 0 𝑦2 0.1200
( ) (𝑦 ) = ( )
0 0.9375 −2.0156 1.0625 3 0.1200
0 0 0.9444 −2.0123 𝑦4 −3.0468

𝑦1
𝑦2
(𝑦 ) = ( )
3
𝑦4

b) Boundary condition with derivative (Initial)

Consider the general linear two point BVP,

𝑦 ′′ (𝑥) + 𝑝(𝑥)𝑦 ′ (𝑥) + 𝑞(𝑥)𝑦(𝑥) = 𝑟(𝑥); 𝑎≤𝑥≤𝑏

With the boundary condition (with derivative 𝑥 = 𝑎)

𝑘1 𝑦(𝑎) + 𝑘2 𝑦′(𝑎) = 𝛼 and 𝑦(𝑏) = 𝛽

To derive the finite-difference equation, the interval [a,b] is divided by step size h,

First boundary condition at Second boundary condition at


𝑘1 𝑦(𝑎) + 𝑘2 𝑦′(𝑎) = 𝛼 𝑥=𝑏
𝑘1 𝑦(𝑥0 ) + 𝑘2 𝑦′(𝑥0 ) = 𝛼 𝑦(𝑏) = 𝛽
𝑘1 𝑦0 + 𝑘2 𝑦′0 = 𝛼 𝑦(𝑥𝑛 ) = 𝛽
𝑦1 − 𝑦−1 𝑦𝑛 = 𝛽
𝑘1 𝑦0 + 𝑘2 ( )=𝛼
2ℎ
2ℎ𝑘1
𝑦−1 =
𝑘2
CECB423 Numerical Methods for Civil Engineers

At grid points 𝑥 = 𝑥𝑖 , the differential equation can be written as

𝑦 ′′ (𝑥𝑖 ) + 𝑝(𝑥𝑖 )𝑦 ′ (𝑥𝑖 ) + 𝑞(𝑥𝑖 )𝑦(𝑥𝑖 ) = 𝑟(𝑥𝑖 )

By using central differentiation


𝑦𝑖+1 − 𝑦𝑖−1
𝑦 ′ (𝑥𝑖 ) ≈
2ℎ
′′ (𝑥 )
𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1
𝑦 𝑖 ≈
ℎ2
Substituting the approximation into above equation,

𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 𝑦𝑖+1 − 𝑦𝑖−1


[ ] + 𝑝𝑖 [ ] + 𝑞𝑖 𝑦𝑖 = 𝑟𝑖
ℎ2 2ℎ

And multiplying throughout by h2



𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 + 𝑝𝑖 (𝑦𝑖+1 − 𝑦𝑖−1 ) + ℎ2 𝑞𝑖 𝑦𝑖 = ℎ2 𝑟𝑖
2

Rearrange the equation,

ℎ ℎ
(1 − 𝑝𝑖 )𝑦𝑖−1 + (−2 + ℎ2 𝑞𝑖 )𝑦𝑖 + (1 + 𝑝𝑖 )𝑦𝑖+1 = ℎ2 𝑟𝑖
2 2

Expanding the finite difference equation for 𝑖 = 1,2,3, … . , 𝑛


i.e:

at i=0 ℎ ℎ
(1 − 𝑝0 )𝑦−1 + (−2 + ℎ2 𝑞0 )𝑦0 + (1 + 𝑝0 )𝑦1 = ℎ2 𝑟0
2 2
ℎ 2ℎ𝑘1 ℎ
(1 − 𝑝0 )( ) + (−2 + ℎ2 𝑞0 )𝑦0 + (1 + 𝑝0 )𝑦1 = ℎ2 𝑟0
2 𝑘2 2

at i=1 ℎ ℎ
(1 − 𝑝1 )𝑦0 + (−2 + ℎ2 𝑞1 )𝑦1 + (1 + 𝑝1 )𝑦2 = ℎ2 𝑟1
2 2

at i=2 ℎ ℎ
(1 − 𝑝2 )𝑦1 + (−2 + ℎ2 𝑞2 )𝑦2 + (1 + 𝑝2 )𝑦3 = ℎ2 𝑟2
2 2

Combine all equation in linear system of from 𝐴𝑦 = 𝑏

Solve the value of 𝑦0 , 𝑦1 , 𝑦2 , … … … . , 𝑦𝑛


CECB423 Numerical Methods for Civil Engineers

Example:

Solve the BVP


1 1
𝑦 ′′ + 𝑦 ′ + 2 𝑦(𝑥𝑖 ) = 3; 𝑦 ′ (1) + 𝑦(1) = 1, 𝑦(2) = 3
𝑥 𝑥

For x at interval [1,2] with h=0.2. Use four decimal places in all calculation.

First boundary condition at Second boundary condition at


𝑦 ′ (1) + 𝑦(1) = 1, 𝑦(2) = 3
𝑦′0 + 𝑦0 = 1 𝑦(𝑥5 ) = 3
𝑦1 − 𝑦−1 𝑦5 = 3
+ 𝑦0 = 1
2ℎ
𝑦1 − 𝑦−1 + 2ℎ𝑦0 = 2ℎ
𝑦−1 = −0.4 + 0.4𝑦0 + 𝑦1

1 1
𝑦 ′′ + 𝑦 ′ + 2 𝑦(𝑥𝑖 ) = 3
𝑥 𝑥
𝑦 ′′ (𝑥) + 𝑝(𝑥)𝑦 ′ (𝑥) + 𝑞(𝑥)𝑦(𝑥) = 𝑟(𝑥)

ℎ ℎ
(1 − 𝑝𝑖 )𝑦𝑖−1 + (−2 + ℎ2 𝑞𝑖 )𝑦𝑖 + (1 + 𝑝𝑖 )𝑦𝑖+1 = ℎ2 𝑟𝑖
2 2

at i=0 ℎ ℎ
(1 − 𝑝0 )𝑦−1 + (−2 + ℎ2 𝑞0 )𝑦0 + (1 + 𝑝0 )𝑦1 = ℎ2 𝑟0
2 2
x0=1.0
ℎ 1 1 ℎ 1
(1 − ∗ ) (−0.4 + 0.4𝑦0 + 𝑦1 ) + (−2 + ℎ2 ∗ 2
) 𝑦0 + (1 + ∗ ) 𝑦1 = ℎ2 ∗ 3
2 𝑥0 (𝑥0 ) 2 𝑥0
0.2 1 1 0.2 1
(1 − ∗ ) (−0.4 + 0.4𝑦0 + 𝑦1 ) + (−2 + 0.22 ∗ ) 𝑦0 + (1 + ∗ ) 𝑦 = 0.22 ∗ 3
2 1.0 1.02 2 1.0 1
0.90(−0.4 + 0.4𝑦0 + 𝑦1 ) − 2.0400𝑦0 + 1.1000𝑦1 = 0.12
−𝟏. 𝟔𝟖𝟎𝟎𝒚𝟎 + 𝟐. 𝟎𝟎𝟎𝟎𝒚𝟏 = 𝟎. 𝟒𝟖𝟎𝟎
CECB423 Numerical Methods for Civil Engineers

at i=1 ℎ ℎ
(1 − 𝑝1 )𝑦0 + (−2 + ℎ2 𝑞1 )𝑦1 + (1 + 𝑝1 )𝑦2 = ℎ2 𝑟1
2 2
x1=1.2
ℎ 1 1 ℎ 1
(1 − ∗ ) 𝑦0 + (−2 + ℎ2 ∗ 2
) 𝑦1 + (1 + ∗ ) 𝑦2 = ℎ2 ∗ 3
2 𝑥1 (𝑥1 ) 2 𝑥1
0.2 1 1 0.2 1
(1 − ∗ ) 𝑦0 + (−2 + 0.22 ∗ ) 𝑦1 + (1 + ∗ ) 𝑦 = 0.22 ∗ 3
2 1.2 1.2 2 2 1.2 2
𝟎. 𝟗𝟏𝟔𝟕𝒚𝟎 − 𝟐. 𝟎𝟐𝟕𝟖𝒚𝟏 + 𝟏. 𝟎𝟖𝟑𝟑𝒚𝟐 = 𝟎. 𝟏𝟐

at i=2 ℎ ℎ
(1 − 𝑝2 )𝑦1 + (−2 + ℎ2 𝑞2 )𝑦2 + (1 + 𝑝2 )𝑦3 = ℎ2 𝑟2
2 2
x2=1.4
ℎ 1 1 ℎ 1
(1 − ∗ ) 𝑦1 + (−2 + ℎ2 ∗ 2
) 𝑦2 + (1 + ∗ ) 𝑦3 = ℎ2 ∗ 3
2 𝑥2 (𝑥2 ) 2 𝑥2
0.2 1 1 0.2 1
(1 − ∗ ) 𝑦1 + (−2 + 0.22 ∗ ) 𝑦2 + (1 + ∗ ) 𝑦 = 0.22 ∗ 3
2 1.4 1.4 2 2 1.4 3
𝟎. 𝟗𝟐𝟖𝟔𝒚𝟏 − 𝟐. 𝟎𝟐𝟎𝟒𝒚𝟐 + 𝟏. 𝟎𝟕𝟏𝟒𝒚𝟑 = 𝟎. 𝟏𝟐

at i=3 ℎ ℎ
(1 − 𝑝3 )𝑦2 + (−2 + ℎ2 𝑞3 )𝑦3 + (1 + 𝑝3 )𝑦4 = ℎ2 𝑟3
2 2
x3=1.6
ℎ 1 1 ℎ 1
(1 − ∗ ) 𝑦2 + (−2 + ℎ2 ∗ 2
) 𝑦3 + (1 + ∗ ) 𝑦4 = ℎ2 ∗ 3
2 𝑥3 (𝑥3 ) 2 𝑥3
0.2 1 1 0.2 1
(1 − ∗ ) 𝑦2 + (−2 + 0.22 ∗ ) 𝑦3 + (1 + ∗ ) 𝑦 = 0.22 ∗ 3
2 1.6 1.6 2 2 1.6 4
𝟎. 𝟗𝟑𝟕𝟓𝒚𝟐 − 𝟐. 𝟎𝟏𝟓𝟔𝒚𝟑 + 𝟏. 𝟎𝟔𝟐𝟓𝒚𝟒 = 𝟎. 𝟏𝟐

at i=4 ℎ ℎ
(1 − 𝑝4 )𝑦3 + (−2 + ℎ2 𝑞4 )𝑦4 + (1 + 𝑝4 )𝑦5 = ℎ2 𝑟4
2 2
x4=1.8
ℎ 1 1 ℎ 1
(1 − ∗ ) 𝑦3 + (−2 + ℎ2 ∗ 2
) 𝑦4 + (1 + ∗ ) 𝑦5 = ℎ2 ∗ 3
2 𝑥4 (𝑥4 ) 2 𝑥4
0.2 1 1 0.2 1
(1 − ∗ ) 𝑦3 + (−2 + 0.22 ∗ 2
) 𝑦4 + (1 + ∗ ) (3) = 0.22 ∗ 3
2 1.8 1.8 2 1.8
0.9444𝑦3 − 2.0123𝑦4 + 3.1668 = 0.12
𝟎. 𝟗𝟒𝟒𝟒𝒚𝟑 − 𝟐. 𝟎𝟏𝟐𝟑𝒚𝟒 = −𝟑. 𝟎𝟒𝟔𝟖
CECB423 Numerical Methods for Civil Engineers

Solve the system using trigonal system

−1.6800 2.0000 0 0 0 𝑦0 0.4800


0.9167 −0.0278 1.0833 0 0 𝑦1 0.1200
0 0.9286 −2.0204 1.0714 0 𝑦2 = 0.1200
0 0 0.9375 −2.0156 1.0625 𝑦3 0.1200
( 0 0 0 0.9444 −2.0123) (𝑦4 ) (−3.0468)

𝑦0 1.9081
𝑦1 1.8428
𝑦2 = 1.9455
𝑦3 2.1837
𝑦
( 4 ) (2.5388)

c) Boundary condition with derivative (End)

Consider the general linear two point BVP,

𝑦 ′′ (𝑥) + 𝑝(𝑥)𝑦 ′ (𝑥) + 𝑞(𝑥)𝑦(𝑥) = 𝑟(𝑥); 𝑎≤𝑥≤𝑏

With the boundary condition (with derivative 𝑥 = 𝑏)

𝑦(𝑎) = 𝛼 and 𝑘1 𝑦(𝑏) + 𝑘2 𝑦′(𝑏) = 𝛽

To derive the finite-difference equation, the interval [a,b] is divided by step size h,

First boundary condition at Second boundary condition at


𝑥=𝑎 𝑘1 𝑦(𝑏) + 𝑘2 𝑦′(𝑏) = 𝛽
𝑦(𝑎) = 𝛼 𝑘1 𝑦(𝑥𝑛 ) + 𝑘2 𝑦′(𝑥𝑛 ) = 𝛽
𝑦(𝑥0 ) = 𝛼 𝑘1 𝑦𝑛 + 𝑘2 𝑦′𝑛 = 𝛽
𝑦0 = 𝛼 𝑦𝑛+1 − 𝑦𝑛−1
𝑘1 𝑦𝑛 + 𝑘2 ( )=𝛽
2ℎ
2ℎ𝑘1 2ℎ
𝑦𝑛+1 = 𝑦𝑛−1 − 𝑦𝑛 + 𝛽
𝑘2 𝑘2
CECB423 Numerical Methods for Civil Engineers

At grid points 𝑥 = 𝑥𝑖 , the differential equation can be written as

𝑦 ′′ (𝑥𝑖 ) + 𝑝(𝑥𝑖 )𝑦 ′ (𝑥𝑖 ) + 𝑞(𝑥𝑖 )𝑦(𝑥𝑖 ) = 𝑟(𝑥𝑖 )

By using central differentiation


𝑦𝑖+1 − 𝑦𝑖−1
𝑦 ′ (𝑥𝑖 ) ≈
2ℎ
′′ (𝑥 )
𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1
𝑦 𝑖 ≈
ℎ2
Substituting the approximation into above equation,

𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 𝑦𝑖+1 − 𝑦𝑖−1


[ ] + 𝑝𝑖 [ ] + 𝑞𝑖 𝑦𝑖 = 𝑟𝑖
ℎ2 2ℎ

And multiplying throughout by h2



𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 + 𝑝𝑖 (𝑦𝑖+1 − 𝑦𝑖−1 ) + ℎ2 𝑞𝑖 𝑦𝑖 = ℎ2 𝑟𝑖
2

Rearrange the equation,

ℎ ℎ
(1 − 𝑝𝑖 )𝑦𝑖−1 + (−2 + ℎ2 𝑞𝑖 )𝑦𝑖 + (1 + 𝑝𝑖 )𝑦𝑖+1 = ℎ2 𝑟𝑖
2 2

Expanding the finite difference equation for 𝑖 = 1,2,3, … . , 𝑛


i.e:

at i=1 ℎ ℎ
(1 − 𝑝1 )𝑦0 + (−2 + ℎ2 𝑞1 )𝑦1 + (1 + 𝑝1 )𝑦2 = ℎ2 𝑟1
2 2

at i=2 ℎ ℎ
(1 − 𝑝2 )𝑦1 + (−2 + ℎ2 𝑞2 )𝑦2 + (1 + 𝑝2 )𝑦3 = ℎ2 𝑟2
2 2

at i=n ℎ ℎ
(1 − 𝑝𝑛 )𝑦𝑛−1 + (−2 + ℎ2 𝑞𝑛 )𝑦𝑛 + (1 + 𝑝𝑛 )𝑦𝑛+1 = ℎ2 𝑟𝑛
2 2
ℎ ℎ 2ℎ𝑘1 2ℎ
(1 − 𝑝𝑛 )𝑦𝑛−1 + (−2 + ℎ2 𝑞𝑛 )𝑦𝑛 + (1 + 𝑝𝑛 )(𝑦𝑛−1 − 𝑦 + 𝛽) = ℎ2 𝑟𝑛
2 2 𝑘2 𝑛 𝑘2

Combine all equation in linear system of from 𝐴𝑦 = 𝑏

Solve the value of 𝑦1 , 𝑦2 , 𝑦3 , … … … . , 𝑦𝑛


CECB423 Numerical Methods for Civil Engineers

Example:

Solve the BVP


𝑦 ′′ + 2𝑥𝑦 ′ − 3𝑦 = −6𝑒 −𝑥 (1 + 𝑥 2 ); 𝑦(0) = 0, 𝑦 ′ (1) = 0,

For x at interval [0,1] with h=0.2. Use four decimal places in all calculation.

First boundary condition at Second boundary condition at


𝑦(0) = 0 𝑦 ′ (1) = 0
𝑦(𝑥0 ) = 0 𝑦 ′ (𝑥5 ) = 0
𝑦0 = 0 𝑦6 − 𝑦4
=0
2ℎ
𝑦6 − 𝑦4 = 0
𝑦6 = 𝑦4

𝑦 ′′ + 2𝑥𝑦 ′ − 3𝑦 = −6𝑒 −𝑥 (1 + 𝑥 2 )

𝑦 ′′ (𝑥) + 𝑝(𝑥)𝑦 ′ (𝑥) + 𝑞(𝑥)𝑦(𝑥) = 𝑟(𝑥)

ℎ ℎ
(1 − 𝑝𝑖 )𝑦𝑖−1 + (−2 + ℎ2 𝑞𝑖 )𝑦𝑖 + (1 + 𝑝𝑖 )𝑦𝑖+1 = ℎ2 𝑟𝑖
2 2

at i=1 ℎ ℎ
(1 − 𝑝1 )𝑦0 + (−2 + ℎ2 𝑞1 )𝑦1 + (1 + 𝑝1 )𝑦2 = ℎ2 𝑟1
2 2
x1=0.2 ℎ ℎ
(1 − ∗ 2𝑥1 ) 𝑦0 + (−2 + ℎ2 ∗ (−3))𝑦1 + (1 + ∗ 2𝑥1 ) 𝑦2 = ℎ2 ∗ −6𝑒 −𝑥1 (1 + (𝑥1 )2 )
2 2
0.2 0.2
(1 − ∗ 2(0.2)) (0) + (−2 + 0.22 ∗ (−3))𝑦1 + (1 + ∗ 2(0.2)) 𝑦2 = 0.22 ∗ −6𝑒 −0.2 (1 + (0.2)2 )
2 2
−𝟐. 𝟏𝟐𝒚𝟏 + 𝟏. 𝟎𝟒𝒚𝟐 = −𝟎. 𝟐𝟎𝟒𝟒
CECB423 Numerical Methods for Civil Engineers

at i=2 ℎ ℎ
(1 − 𝑝2 )𝑦1 + (−2 + ℎ2 𝑞2 )𝑦2 + (1 + 𝑝2 )𝑦3 = ℎ2 𝑟2
2 2
x2=0.4 ℎ ℎ
(1 − ∗ 2𝑥2 ) 𝑦1 + (−2 + ℎ2 ∗ (−3))𝑦2 + (1 + ∗ 2𝑥2 ) 𝑦3 = ℎ2 ∗ −6𝑒 −𝑥2 (1 + (𝑥2 )2 )
2 2
0.2 0.2
(1 − ∗ 2(0.4)) 𝑦1 + (−2 + 0.22 ∗ (−3))𝑦2 + (1 + ∗ 2(0.4)) 𝑦3 = 0.22 ∗ −6𝑒 −0.4 (1 + (0.4)2 )
2 2
𝟎. 𝟗𝟐𝒚𝟏 − 𝟐. 𝟏𝟐𝒚𝟐 + 𝟏. 𝟎𝟒𝒚𝟑 = −𝟎. 𝟏𝟖𝟔𝟔

at i=3 ℎ ℎ
(1 − 𝑝3 )𝑦2 + (−2 + ℎ2 𝑞3 )𝑦3 + (1 + 𝑝3 )𝑦4 = ℎ2 𝑟3
2 2
x3=0.6 ℎ ℎ
(1 − ∗ 2𝑥3 ) 𝑦2 + (−2 + ℎ2 ∗ (−3))𝑦3 + (1 + ∗ 2𝑥3 ) 𝑦4 = ℎ2 ∗ −6𝑒 −𝑥3 (1 + (𝑥3 )2 )
2 2
0.2 0.2
(1 − ∗ 2(0.6)) 𝑦2 + (−2 + 0.22 ∗ (−3))𝑦3 + (1 + ∗ 2(0.6)) 𝑦4 = 0.22 ∗ −6𝑒 −0.6 (1 + (0.6)2 )
2 2
𝟎. 𝟖𝟖𝒚𝟐 − 𝟐. 𝟏𝟐𝒚𝟑 + 𝟏. 𝟏𝟐𝒚𝟒 = −𝟎. 𝟏𝟕𝟗𝟏

at i=4 ℎ ℎ
(1 − 𝑝4 )𝑦3 + (−2 + ℎ2 𝑞4 )𝑦4 + (1 + 𝑝4 )𝑦5 = ℎ2 𝑟4
2 2
x4=0.8 ℎ ℎ
(1 − ∗ 2𝑥4 ) 𝑦3 + (−2 + ℎ2 ∗ (−3))𝑦4 + (1 + ∗ 2𝑥3 ) 𝑦5 = ℎ2 ∗ −6𝑒 −𝑥3 (1 + (𝑥4 )2 )
2 2
0.2 0.2
(1 − ∗ 2(0.8)) 𝑦3 + (−2 + 0.22 ∗ (−3))𝑦4 + (1 + ∗ 2(0.8)) 𝑦5 = 0.22 ∗ −6𝑒 −0.8 (1 + (0.8)2 )
2 2
𝟎. 𝟖𝟒𝒚𝟐 − 𝟐. 𝟏𝟐𝒚𝟑 + 𝟏. 𝟏𝟔𝒚𝟒 = −𝟎. 𝟏𝟕𝟔𝟗

at i=5 ℎ ℎ
(1 − 𝑝5 )𝑦4 + (−2 + ℎ2 𝑞5 )𝑦5 + (1 + 𝑝5 )𝑦6 = ℎ2 𝑟5
2 2
x5=1.0 ℎ ℎ
(1 − ∗ 2𝑥5 ) 𝑦4 + (−2 + ℎ2 ∗ (−3))𝑦5 + (1 + ∗ 2𝑥5 ) 𝑦6 = ℎ2 ∗ −6𝑒 −𝑥5 (1 + (𝑥5 )2 )
2 2
0.2 0.2
(1 − ∗ 2(1.0)) 𝑦4 + (−2 + 0.22 ∗ (−3))𝑦5 + (1 + ∗ 2(1.0)) 𝑦6 = 0.22 ∗ −6𝑒 −1 (1 + (1.0)2 )
2 2
𝟎. 𝟖𝟎𝒚𝟒 − 𝟐. 𝟏𝟐𝒚𝟓 + 𝟏. 𝟐𝒚𝟔 = −𝟎. 𝟏𝟕𝟔𝟔
Based on second derivative
0.80𝑦4 − 2.12𝑦5 + 1.2𝑦4 = −0.1766
𝟐. 𝟎𝟎𝒚𝟒 − 𝟐. 𝟏𝟐𝒚𝟓 = −𝟎. 𝟏𝟕𝟔𝟔
CECB423 Numerical Methods for Civil Engineers

Solve the system using trigonal system

−2.12 1.04 0 0 0 𝑦1 −0.2044


0.92 −2.12 1.04 0 0 𝑦2 −0.1866
0 0.88 −2.12 1.12 0 𝑦3 = −0.1791
0 0 0.84 −2.12 1.16 𝑦4 −0.1769
( 0 0 0 2.00 −2.12) (𝑦5 ) (−0.1766)

𝑦1 0.4897
𝑦2 0.8017
𝑦3 = 0.9838
𝑦4 1.0724
𝑦
( 5 ) (1.0950)

d) Boundary condition with derivative (Both)


CECB423 Numerical Methods for Civil Engineers

Partial Differential Equations (PDE).

Partial differential question (PDE) are differential equations involving more than one
independent variable. We consider a general second-order PDE in two independent
variable x and y which is written as

𝛿 2𝑢 𝛿 2𝑢 𝛿 2𝑢 𝛿𝑢 𝛿𝑢
𝐴 2
+ 𝐵 + 𝐶 2
+𝐷 +𝐸 + 𝐹𝑢 = 𝐺
𝛿𝑥 𝛿𝑥𝛿𝑦 𝛿𝑦 𝛿𝑥 𝛿𝑦
Or
𝐴𝑢𝑥𝑥 + 𝐵𝑢𝑥𝑦 + 𝐶𝑢𝑦𝑦 + 𝐷𝑢𝑥 + 𝐸𝑢𝑦 + 𝐹𝑢 = 𝐺

Where A, B, C, D, E, F and G are constants or functions of x and y. These PDEs are


classified into three group.

Elliptic <0
2
PDE is called Parabolic if 𝐵 − 4𝐴𝐶 =0
Hyperbolic >0

Determine either the equation is elliptic, parabolic or hyperbolic.

𝛿2 𝑢 𝛿2 𝑢
1. Laplace equation, 𝛿𝑥 2 + 𝛿𝑦 2 = 0

𝛿2 𝑢 𝛿2 𝑢
2. Poisson equation 𝛿𝑥 2 + 𝛿𝑦 2 = 𝑓(𝑥, 𝑦)

𝛿2𝑢 𝛿𝑢
3. Heat equation 𝑐 𝛿𝑥 2 = 𝛿𝑡

𝛿2 𝑢 𝛿2 𝑢
4. Wave equation 𝑐 𝛿𝑥 2 = 𝛿𝑡 2
CECB423 Numerical Methods for Civil Engineers

Elliptic Equations
Finite difference method for the numerical solution of the PDEs of elliptic type.
Consider the Poisson equation,
𝛿 2𝑢 𝛿 2𝑢
+ = 𝑓(𝑥, 𝑦)
𝛿𝑥 2 𝛿𝑦 2
With boundary condition
𝑢(𝑥, 0) = 𝑓1 (𝑥), 𝑢(𝑥, 𝑏) = 𝑓2 (𝑥), 0<𝑥<𝑎
𝑢(0, 𝑦) = 𝑔1 (𝑥), 𝑢(𝑎, 𝑦) = 𝑔2 (𝑥), 0<𝑦<𝑏

Create Domain

In order to approximate the solution to PDE elliptic using finite difference method the
𝑎 𝑏
rectangular domain is partitioned into a grids ∆𝑥 = ℎ = 𝑛 and ∆𝑦 = 𝑘 = 𝑚 as shown in
figure below

𝛿 2𝑢 𝛿 2𝑢
+ = 𝑓(𝑥, 𝑦)
𝛿𝑥 2 𝛿𝑦 2
At point (𝑥𝑖 , 𝑦𝑗 )

𝛿 2 𝑢(𝑥𝑖 , 𝑦𝑗 ) 𝛿 2 𝑢(𝑥𝑖 , 𝑦𝑗 )
+ = 𝑓((𝑥𝑖 , 𝑦𝑗 )
𝛿𝑥 2 𝛿𝑦 2
CECB423 Numerical Methods for Civil Engineers

using finite difference approximation

𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝑢𝑖,𝑗+1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1


+ = 𝑓𝑖,𝑗
ℎ2 𝑘2

multiply both side ℎ2


ℎ2
𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 + 2 (𝑢𝑖,𝑗+1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 ) = ℎ2 𝑓𝑖,𝑗
𝑘

Create equation and solve using Ax=b system

Example 1:
𝛿 2𝑢 𝛿 2𝑢
+ = 𝑥𝑒 𝑦 0 <𝑥 < 2; 0<𝑦<1
𝛿𝑥 2 𝛿𝑦 2
With boundary conditions

𝑢(0, 𝑦) = 0, 𝑢(2, 𝑦) = 2𝑒 𝑦 0<𝑦<1


𝑢(𝑥, 0) = 𝑥, 𝑢(𝑥, 1) = 𝑥𝑒 𝑦 0<𝑥<2

Using finite difference method with ∆𝑥 = ℎ = 0.5 and ∆𝑦 = 𝑘 = 0.5


Solve the linear system 𝐴𝑥 = 𝑏 using Gauss Jordan method. Use three decimal places in
all calculation.
CECB423 Numerical Methods for Civil Engineers

Approximate 𝑢1,1 , 𝑢2,1 𝑎𝑛𝑑 𝑢3,1


At point (𝑥𝑖 , 𝑦𝑗 )

𝛿 2 𝑢(𝑥𝑖 , 𝑦𝑗 ) 𝛿 2 𝑢(𝑥𝑖 , 𝑦𝑗 )
+ = 𝑥𝑖 𝑒 𝑦𝑖
𝛿𝑥 2 𝛿𝑦 2

using finite difference approximation

𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝑢𝑖,𝑗+1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1


+ = 𝑥𝑖 𝑒 𝑦𝑖
ℎ2 𝑘2

multiply both side ℎ2


ℎ2
𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 + (𝑢 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 ) = ℎ2 𝑥𝑖 𝑒 𝑦𝑖
𝑘 2 𝑖,𝑗+1

Given ℎ = 𝑘 = 0.5

0.52
𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 + (𝑢 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 ) = 0.52 𝑥𝑖 𝑒 𝑦𝑖
0.52 𝑖,𝑗+1

𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 = 0.52 𝑥𝑖 𝑒 𝑦𝑖

𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 − 4𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 = 0.52 𝑥𝑖 𝑒 𝑦𝑖

(𝑥1 , 𝑦1 ) 𝑢2,1 + 𝑢0,1 − 4𝑢1,1 + 𝑢1,2 + 𝑢1,0 = 0.52 𝑥1 𝑒 𝑦1


at i=1, j=1 𝑢2,1 + 0 − 4𝑢1,1 + 1.359 + 0.5 = 0.52 (0.5)𝑒 0.5
𝑢2,1 − 4𝑢1,1 = −1.653

(𝑥2 , 𝑦1 ) 𝑢3,1 + 𝑢1,1 − 4𝑢2,1 + 𝑢2,2 + 𝑢2,0 = 0.52 𝑥2 𝑒 𝑦1


at i=2, j=1 𝑢3,1 + 𝑢1,1 − 4𝑢2,1 + 2.718 + 1 = 0.52 (1)𝑒 0.5
𝑢3,1 + 𝑢1,1 − 4𝑢2,1 = −3.306

(𝑥3 , 𝑦1 ) 𝑢4,1 + 𝑢2,1 − 4𝑢3,1 + 𝑢3,2 + 𝑢3,0 = 0.52 𝑥3 𝑒 𝑦1


at i=3, j=1 3.297 + 𝑢2,1 − 4𝑢3,1 + 4.077 + 1.5 = 0.52 𝑥3 𝑒 𝑦1
𝑢2,1 − 4𝑢3,1 = −8.256
CECB423 Numerical Methods for Civil Engineers

Equation (1) till (3) can be express in matrix form

−4 1 0 𝑢1,1 −1.653
𝑢
( 1 −4 1 ) ( 2,1 ) = (−3.306)
0 1 −4 𝑢3,1 −8.256

Consider the Laplace equation,


𝛿 2𝑢 𝛿 2𝑢
+ =0
𝛿𝑥 2 𝛿𝑦 2
The method to solve Laplace equation similar to solve Poisson’s equation with
𝑓(𝑥, 𝑦) = 0

Example 2:
𝛿 2𝑢 𝛿 2𝑢
+ =0 0< 𝑥 < 3; 0<𝑦<1
𝛿𝑥 2 𝛿𝑦 2
With boundary conditions

𝑢(0, 𝑦) = 0, 𝑢(3, 𝑦) = 0 0 < 𝑦 < 1


𝑢(𝑥, 0) = 𝑥(3 − 𝑥), 𝑢(𝑥, 1) = 0 0 < 𝑥 < 3

Using finite difference method with ∆𝑥 = ℎ = 1 and ∆𝑦 = 𝑘 = 1/3


Solve the linear system 𝐴𝑥 = 𝑏 using Gauss Jordan method. Use three decimal places in
all calculation.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy