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

FiniteDifferenceApprox Notes

Numerical Analysis UH

Uploaded by

vietnam192002
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)
29 views

FiniteDifferenceApprox Notes

Numerical Analysis UH

Uploaded by

vietnam192002
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/ 10

Another Approach to Two-Point Boundary Value Problems

Focus: Linear problems with Dirichlet boundary conditions.

𝑢′′(𝑥) = 𝑝(𝑥)𝑢′(𝑥) + 𝑞(𝑥)𝑢(𝑥) + 𝑓(𝑥), 𝑎≤𝑥≤𝑏


{ }
𝑢(𝑎) = 𝛼, 𝑢(𝑏) = 𝛽

𝑝(𝑥), 𝑞(𝑥), 𝑓(𝑥), 𝑎, 𝑏, 𝛼 and 𝛽 are given, and 𝑝(𝑥), 𝑞(𝑥) and 𝑓(𝑥) are continuous functions on [𝑎, 𝑏].

Goal: Approximate the unknown function 𝑢(𝑥).

Review: We previously discussed this problem in Chapter 3, and used three different initial value
problems to approximate the solution.
A different approach:
𝑢′′(𝑥) = 𝑝(𝑥)𝑢′(𝑥) + 𝑞(𝑥)𝑢(𝑥) + 𝑓(𝑥), 𝑎 ≤ 𝑥 ≤ 𝑏
{ } (3)
𝑢(𝑎) = 𝛼, 𝑢(𝑏) = 𝛽

The approach here is very different, but serves as a good lead-in to approximation of solutions to more
complicated problems associated with partial differential equations (see Math 4365 for more
information), where shooting methods cannot be used.

Recall: If ℎ > 0 then the following centered difference approximations are 𝑂(ℎ2 ).
𝑢(𝑥 + ℎ) − 𝑢(𝑥 − ℎ)
𝑢′ (𝑥) ≈
2ℎ

𝑢(𝑥 + ℎ) − 2𝑢(𝑥) + 𝑢(𝑥 − ℎ)


𝑢′′ (𝑥) ≈
ℎ2

Let’s use these in our present system.


𝑏−𝑎
Step 1: Choose a relatively large positive integer 𝑛, creating a step size ℎ = 𝑛
, and creating the points

𝑥0 = 𝑎, 𝑥1 = 𝑎 + ℎ, 𝑎2 = 𝑎 + 2ℎ, … , 𝑥𝑛−1 = 𝑎 + (𝑛 − 1)ℎ, 𝑥𝑛 = 𝑏.

These are the points where we hope to approximate our solution. Now, define our approximations to
𝑢(𝑥𝑖 ) to be denoted by 𝑢𝑖 for each 𝑖. Then the centered difference approximations above become
𝑢(𝑥𝑖 + ℎ) − 𝑢(𝑥𝑖 − ℎ) 𝑢𝑖+1 − 𝑢𝑖−1
𝑢′ (𝑥𝑖 ) ≈ ≈
2ℎ 2ℎ
and

(𝑢(𝑥𝑖 + ℎ) − 2𝑢(𝑥𝑖 ) + 𝑢(𝑥𝑖 − ℎ)) 𝑢𝑖+1 − 2𝑢𝑖 + 𝑢𝑖−1


𝑢′′ (𝑥𝑖 ) ≈ ≈ .
ℎ2 ℎ2
Step 2: Substitute the approximations above into
𝑢′′(𝑥) = 𝑝(𝑥)𝑢′(𝑥) + 𝑞(𝑥)𝑢(𝑥) + 𝑓(𝑥)
for each 𝑥 = 𝑥𝑖 , with 𝑖 = 1, … , 𝑛 − 1. Start by viewing the equations for each 𝑖 = 1, … , 𝑛 − 1.
𝑢′′(𝑥1 ) = 𝑝(𝑥1 )𝑢′(𝑥1 ) + 𝑞(𝑥1 )𝑢(𝑥1 ) + 𝑓(𝑥1 )
𝑢′′(𝑥2 ) = 𝑝(𝑥2 )𝑢′(𝑥2 ) + 𝑞(𝑥2 )𝑢(𝑥2 ) + 𝑓(𝑥2 )
( )

𝑢′′(𝑥𝑛−1 ) = 𝑝(𝑥𝑛−1 )𝑢′(𝑥𝑛−1 ) + 𝑞(𝑥𝑛−1 )𝑢(𝑥𝑛−1 ) + 𝑓(𝑥𝑛−1 )

Now, make the substitutions.

𝑢2 − 2𝑢1 + 𝑢0 (𝑢2 − 𝑢0 )
2
= 𝑝1 + 𝑞1 𝑢1 + 𝑓1
ℎ 2ℎ
𝑢3 − 2𝑢2 + 𝑢1 (𝑢3 − 𝑢1 )
2
= 𝑝2 + 𝑞2 𝑢2 + 𝑓2
ℎ 2ℎ

𝑢𝑛 − 2𝑢𝑛−1 + 𝑢𝑛−2 (𝑢𝑛 − 𝑢𝑛−2 )
( = 𝑝𝑛−1 + 𝑞𝑛−1 𝑢𝑛−1 + 𝑓𝑛−1 )
ℎ2 2ℎ

Notes:

• 𝑢0 is our approximation for 𝑢(𝑥0 ) = 𝑢(𝑎), and we are given 𝑢(𝑎) = 𝛼.


So, we substitute 𝑢0 = 𝛼 above.

• 𝑢𝑛 is our approximation for 𝑢(𝑥𝑛 ) = 𝑢(𝑏), and we are given 𝑢(𝑎) = 𝛽.


So, we substitute 𝑢𝑛 = 𝛽 above.

Then we isolate the 𝑢𝑖 on the left side of each equation, and move everything else to the right side.
This should give
1 1
(−2 − ℎ2 𝑞1 )𝑢1 + (1 − ℎ𝑝1 ) 𝑢2 = ℎ2 𝑓1 − 𝛼(1 + ℎ𝑝1 )
2 2
1 1
(1 + 2 ℎ𝑝2 ) 𝑢1 + (−2 − ℎ2 𝑞2 )𝑢2 + (1 − 2 ℎ𝑝2 ) 𝑢3 = ℎ2 𝑓2
⋮ . (11)
1 2 1 2
(1 + 2 ℎ𝑝𝑛−2 ) 𝑢𝑛−3 + (−2 − ℎ 𝑞𝑛−2 )𝑢𝑛−2 + (1 − 2 ℎ𝑝𝑛−2 ) 𝑢𝑛−1 = ℎ 𝑓𝑛−2
1 2 2 1
( (1 + 2 ℎ𝑝𝑛−1 ) 𝑢𝑛−2 + (−2 − ℎ 𝑞𝑛−1 )𝑢𝑛−1 = ℎ 𝑓𝑛−1 − 𝛽 (1 − 2 ℎ𝑝𝑛−1 ) )

This system can be written in the form


⃗ =𝐹
𝑀𝑈
where
𝑢1 𝑢(𝑥1 )
𝑢2 𝑢(𝑥 2 ) ).
⃗ =(
𝑈 ⋮ )≈( ⋮
𝑢𝑛−1 𝑢(𝑥𝑛−1 )

𝑀 =? 𝐹 =?

Terms: Sparse, tri-diagonal, sub-diagonal, diagonal, super-diagonal


Remarks on Solving
⃗ = 𝐹.
𝑀𝑈
Thomas Algorithm: Given the system 𝑀𝑈 ⃗ = 𝐹 where 𝑀 is an 𝑚 × 𝑚 tridiagonal matrix such that the
sub-diagonal, diagonal and super-diagonal of 𝑀 are the vectors 𝑐, 𝑑 and 𝑒, and 𝐹 ∈ ℝ𝑘 .

Let 𝑘 be the number of entries in the vector 𝑑.


Let 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and 𝐹𝐹 be arrays containing the entries in 𝑐 , 𝑑, 𝑒 and 𝐹 , respectively.
Let 𝑢 = 𝑑𝑑
For each 𝑖 = 2 to 𝑘
𝑐𝑐[𝑖−1]
Let 𝑚 = 𝑑𝑑[𝑖−1]
Let 𝑑𝑑[𝑖] = 𝑑𝑑[𝑖] − 𝑚 ⋅ 𝑒𝑒[𝑖 − 1]
Let 𝐹𝐹[𝑖] = 𝐹𝐹] − 𝑚 ⋅ 𝐹𝐹[𝑖 − 1]
𝐹𝐹[𝑘]
Let 𝑢[𝑘] =
𝑑𝑑[𝑘]
For each 𝑖 = 𝑘 − 1 by −1 to 1
𝐹𝐹[𝑖]−𝑒𝑒[𝑖]⋅𝑢[𝑖+1]
Let 𝑢[𝑖] = 𝑑𝑑[𝑖]
Return 𝑢

Note: VBA and Python code is posted on Space.


Theorem 1: Suppose 𝑝(𝑥), 𝑞(𝑥) and 𝑓(𝑥) are continuous functions, and 𝛼, 𝛽 ∈ ℝ. If (3) has a unique
𝑏−𝑎
solution, and ℎ = 𝑛 is sufficiently small (i.e. 𝑛 is sufficiently large), then (11) will have a unique
𝑢1
𝑢2
⃗ =(
solution 𝑈 ⋮ ), and there is a value 𝐶 dependent only on 𝑝(𝑥), 𝑞(𝑥), 𝑓(𝑥), 𝑎, 𝑏, 𝛼 and 𝛽 so that
𝑢𝑛−1

|𝑢𝑖 − 𝑢(𝑥𝑖 )| ≤ 𝐶ℎ2 for all 𝑖 = 1, … , 𝑛.

Example 1: Show that the two-point boundary value problem below has a unique solution.
𝑢′′ (𝑥) = −1 − cos(𝑥) − 2𝑥 𝑢(𝑥), 0 ≤ 𝑥 ≤ 1
{ }
𝑢(0) = 1, 𝑢(1) = 2
Then approximate this solution in two ways. First, use the method described in Chapter 3. Then use the
approximation method guaranteed in Theorem 1 using 𝑛 = 100. Finally, compare the two
approximations.

You might also like