Mat2034 Ch03 Numerical Ode
Mat2034 Ch03 Numerical Ode
𝑦 ′ = 𝑓 𝑥, 𝑦 , 𝑦 0 = 𝑦0
possess a solution.
• One way of approximating this solution is to use tangent lines.
• For example, let 𝑦(𝑥) denote the unknown solution of the first-order
initial value problem
𝑦 ′ = 0.1 𝑦 + 0.4𝑥 2 , 𝑦 2 = 4
• When 𝑥 is close to 2 (zoom from Figure 3.1 (a)), the points on the
solution curve are close to the points on the tangent line (the lineal
element).
• Using the point (2, 4), the slope 𝑓 2,4 = 1.8, and the point-slope
form of a line, we find that an equation of the tangent line is
𝑦 = 𝐿(𝑥), where 𝑳 𝒙 = 𝟏. 𝟖𝒙 + 𝟎. 𝟒.
Definition 3.1.1
𝑥𝑛+1 = 𝑥𝑛 + ℎ (2)
𝑦𝑛+1 = 𝑦𝑛 + Slope ℎ (3)
where the value of the (𝑆𝑙𝑜𝑝𝑒) in Eq. (3) is the slope of 𝑦(𝑥) at point
𝑥𝑛 , 𝑦𝑛 .
𝑑𝑦 𝑓(𝑥𝑛 , 𝑦𝑛 )
𝑆𝑙𝑜𝑝𝑒 = ቤ = 𝑓(𝑥0 , 𝑦0 )
𝑑𝑥 𝑥=𝑥 𝑦𝑛+1 − 𝑦𝑛
0
ℎ 𝒚𝒏+𝟏 − 𝒚𝒏
𝑦 𝒇 𝒙𝒏 , 𝒚𝒏 =
𝒉
Exact Solution
𝑦(𝑥)
Numerical Solution
𝑓(𝑥𝑛+1 )
𝑥
𝑥𝑛 ℎ 𝑥𝑛+1 𝒙𝒏+𝟏 = 𝒙𝒏 + 𝒉
School of Mathematical Sciences, Sunway University 9 MAT2034 Mathematical Methods
Euler’s Method for 1st Order ODEs
𝑦
𝑦(𝑥)
A smaller ℎ 𝒚𝒏+𝟏 − 𝒚𝒏
𝑓(𝑥𝑛+1 ) 𝒇 𝒙𝒏 , 𝒚𝒏 =
𝒉
error
𝑦𝑛+1
𝑆𝑙𝑜𝑝𝑒: 𝑓(𝑥𝑛 , 𝑦𝑛 )
𝑦𝑛 𝒚𝒏+𝟏 = 𝒚𝒏 + 𝒉𝒇 𝒙𝒏 , 𝒚𝒏
𝑥 𝒙𝒏+𝟏 = 𝒙𝒏 + 𝒉
𝑥𝑛 ℎ 𝑥𝑛+1
Note:
Euler’s method accumulates a large error as the process proceeds. The
process is known to be very slow and in order to obtain reasonable
accuracy, the value of 𝒉 needs to be smaller.
School of Mathematical Sciences, Sunway University 13 MAT2034 Mathematical Methods
Euler’s Method for 1st Order ODEs
Example 3.1.1
Solution:
(a) Separate variables and integrating, we have
𝑑𝑦
= 2𝑥 and ln y = x 2 + C
𝑦
Using 𝑦 1 = 1, 𝐶 = −1
𝟐
ln 𝑦 = 𝑥 2 − 1 ⟹ 𝒚 = 𝒆𝒙 −𝟏
is the explicit solution of the IVP.
School of Mathematical Sciences, Sunway University 14 MAT2034 Mathematical Methods
Euler’s Method for 1st Order ODEs
Example 3.1.1
Solution:
(b) Using Euler’s formula
𝑦𝑛+1 = 𝑦𝑛 + ℎ𝑓 𝑥𝑛 , 𝑦𝑛 , 𝑛 = 0,1,2,3, …
or 𝑦𝑛+1 = 𝑦𝑛 + ℎ 2𝑥𝑛 , 𝑦𝑛
Then, ℎ = 0.1, 𝑥0 = 1, 𝑦0 = 1, 𝑛 = 0
𝑦1 = 𝑦0 + ℎ 2𝑥0 , 𝑦0 = 1 + 0.1 2 1 1 = 𝟏. 𝟐𝟎𝟎𝟎
which estimate 𝒚 𝟏. 𝟏 .
School of Mathematical Sciences, Sunway University 15 MAT2034 Mathematical Methods
Euler’s Method for 1st Order ODEs
Example 3.1.1
Solution:
(b) If we use ℎ = 0.05, we will take two steps to reach 𝑦(1.1) such as
𝑦1 = 1 + 0.05 2 1 1 = 𝟏. 𝟏𝟎𝟎𝟎
𝑦2 = 1.1000 + 0.05 2 1.05 1.10000 = 𝟏. 𝟐𝟏𝟓𝟓
Here, 𝒚𝟏 ≈ 𝒚 𝟏. 𝟎𝟓 and 𝒚𝟐 ≈ 𝒚 𝟏. 𝟏 .
School of Mathematical Sciences, Sunway University 16 MAT2034 Mathematical Methods
Euler’s Method for 1st Order ODEs
Solution: |𝑎𝑐𝑡𝑢𝑎𝑙 − 𝑦𝑛 | 𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟
× 100
𝒚𝒏+𝟏 = 𝒚𝒏 + 𝒉𝒇 𝒙𝒏 , 𝒚𝒏 , 𝒏 = 𝟎, 𝟏, 𝟐, 𝟑, … . . 𝑎𝑐𝑡𝑢𝑎𝑙 𝑣𝑎𝑙𝑢𝑒
truncation error
ℎ2
𝑦′′(𝑐) , where 𝑥𝑛 < 𝑐 < 𝑥𝑛+1
2!
Similarly, we can get any bounds for the local truncation error for
any 5 steps given in Table 3.1.1. Let say 𝑐 = 𝟏. 𝟓. then we have
1.5 2 −1 2
0.1 2
𝑒 4 1.5 + 2 = 𝟎. 𝟏𝟗𝟐𝟎
2
If ℎ is halved to 0.05 in this example, then the error bound is
0.0480, its one-fourth as much as shown 0.1920.
To compute 𝑦𝑛+1 for 𝑛 = 0,1,2, … from (1), we must at each step, first
∗
use Euler’s formula (2) to obtain an initial estimate 𝒚𝒏+𝟏 .
𝑚𝑎𝑣𝑒
𝒙𝟏 , 𝒚 𝒙𝟏 𝑚1 = 𝑓(𝑥1 , 𝑦1∗ )
Exact
(𝑥1 , 𝑦1 ) 𝑚0 = 𝑓(𝑥0 , 𝑦0 )
(𝑥1 , 𝑦1∗ )
(𝑥0 , 𝑦0 ) 𝑓 𝑥0 , 𝑦0 + 𝑓(𝑥1 , 𝑦1∗ )
𝑚𝑎𝑣𝑒 =
2
𝑥
𝑥0 𝑥1
∗
The value of 𝑦𝑛+1 given by (2) predicts a value of 𝑦(𝑥𝑛 ) whereas
the value of 𝑦𝑛+1 defined by formula (1) corrects this estimate.
It can be shown that the global truncation error for Euler’s method is 𝑂 ℎ .
𝟏 𝟐 1
• A reduction of approximately 𝟐
=4
n xn y*(n) y(n)
0 1 1.0000
1 1.1 1.0000 1.0095
2 1.2 1.0299 1.0404
3 1.3 1.0836 1.0967
4 1.4 1.1687 1.1866
5 1.5 1.2989 1.3260
weighted average
weighted average
Here, the weights 𝑤𝑖 , 𝑖 = 1,2, … , 𝑚 are constants that generally satisfy
𝑤1 + 𝑤2 + 𝑤3 + ⋯ + 𝑤𝑚 = 1
for each 𝑘𝑖 , 𝑖 = 1,2, … , 𝑚 is the function 𝑓 evaluated at a selected point
(𝒙, 𝒚) for which 𝑥𝑛 ≤ 𝑥 ≤ 𝑥𝑛+1 .
We shall see that the 𝒌𝒊 are defined recursively. The number 𝒎 is called
the order of the method.
• The parameters are chosen so that (1) agrees with a Taylor polynomial
of degree 𝑚.
• If a function 𝑦(𝑥) possess 𝑘 + 1 derivatives that are continuous on an
open interval containing 𝑎 and 𝑥, then we can write
𝑦𝑛+1 = 𝑦𝑛 + ℎ 𝑤1 𝑘1 + 𝑤2 𝑘2 + 𝑤3 𝑘3 + 𝑤4 𝑘4
𝑘1 = 𝑓 𝑥𝑛 , 𝑦𝑛
𝑘2 = 𝑓 𝑥𝑛 + 𝛼1 ℎ, 𝑦𝑛 + 𝛽1 ℎ𝑘1
𝑘3 = 𝑓 𝑥𝑛 + 𝛼2 ℎ, 𝑦𝑛 + 𝛽2 ℎ𝑘1 + 𝛽3 ℎ𝑘2 (2)
𝑘4 = 𝑓(𝑥𝑛 + 𝛼3 ℎ, 𝑦𝑛 + 𝛽4 ℎ𝑘1 + 𝛽5 ℎ𝑘2 + 𝛽6 ℎ𝑘3 )
The most commonly used set of values for the parameters yields the
following result;
ℎ
𝑦𝑛+1 = 𝑦𝑛 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4
6
𝑘1 = 𝑓 𝑥𝑛 , 𝑦𝑛
1 1
𝑘2 = 𝑓 𝑥𝑛 + ℎ, 𝑦𝑛 + ℎ𝑘1 (3)
2 2
1 1
𝑘3 = 𝑓 𝑥𝑛 + ℎ, 𝑦𝑛 + ℎ𝑘2
2 2
𝑘4 = 𝑓 𝑥𝑛 + ℎ, 𝑦𝑛 + ℎ𝑘3
Example 3.5.1
Use the RK4 to obtain the approximate value of 𝑦(1.5) for the
solution of the initial-value problem with ℎ = 0.1
𝑦 ′ = 2𝑥𝑦, 𝑦 1 = 1.
Solution:
For 𝑛 = 0, we find 𝑘1 = 𝑓 𝑥0 , 𝑦0 = 2𝑥0 𝑦0 = 𝟐
1 1 1 1
𝑘2 = 𝑓 𝑥0 + ℎ, 𝑦0 + ℎ𝑘1 = 2 1 + 0.1 1 + 0.1 𝟐 = 2.31
2 2 2 2
1 1 1 1
𝑘3 = 𝑓 𝑥0 + ℎ, 𝑦0 + ℎ𝑘2 = 2 1 + 0.1 1 + 0.1 2.31
2 2 2 2
= 2.34255
𝑘4 = 𝑓 𝑥0 + ℎ, 𝑦0 + ℎ𝑘3 = 2 1 + 0.1 1 + 0.1 2.34255 = 2.715361
0.1
Thus, 𝑦1 = 1 + 6 𝟐 + 2 2.31 + 2 2.34255 + 2.715361 = 1.23367435
Example 3.5.1
Solution:
Table 3.5.1 RK4 Method with ℎ = 0.1
Actual
n x(n) k1 k2 k3 k4 y(n) value
0 1.00 2.0000 2.3100 2.3426 2.7154 1.0000 1.0000
1 1.10 2.7141 3.1496 3.1997 3.7287 1.2337 1.2337
2 1.20 3.7265 4.3475 4.4252 5.1876 1.5527 1.5527
3 1.30 5.1836 6.0827 6.2041 7.3195 1.9937 1.9937
4 1.40 7.3126 8.6341 8.8257 10.4826 2.6116 2.6117
5 1.50 3.4902 3.4903
Example 3.5.2
Find a bound for the local truncation errors for the RK4 method
applied to
𝑦 ′ = 2𝑥𝑦, 𝑦 1 = 1.
Solution:
2
Compute the fifth derivative of the known solution 𝑦 𝑥 = 𝑒 𝑥 −1
we get
5
ℎ5 3 5 𝑐 2 −1
ℎ5
𝑦 𝑐 = 120𝑐 + 160𝑐 + 32𝑐 𝑒 (4)
5! 5!
With 𝑐 = 1.5, (4) yields a bound of 0.00028 on the local truncation
error for each of the 5 steps when 𝒉 = 𝟎. 𝟏.
The Table 3.5.1 has shown that the error in 𝑦1 is much lesser than
this bound.
Adams-Bashforth-Moulton Method
• Fourth-order Adams-Bashforth-Moulton
method
• It’s also a predictor – corrector method
• One formula is used to predict a value
∗
𝑦𝑛+1 which in turn is used to obtain a
corrected value 𝑦𝑛+1 .
School of Mathematical Sciences, Sunway University 50 MAT2034 Mathematical Methods
Multistep Methods
Adams-Bashforth-Moulton Method
∗
ℎ ′ ′ ′
𝑦𝑛+1 = 𝑦𝑛 + 55𝑦𝑛′ − 59𝑦𝑛−1 + 37𝑦𝑛−2 − 9𝑦𝑛−3 (5)
24
𝑦𝑛′ = 𝑓 𝑥𝑛 , 𝑦𝑛
′
𝑦𝑛−1 = 𝑓 𝑥𝑛−1 , 𝑦𝑛−1
′
𝑦𝑛−2 = 𝑓 𝑥𝑛−2 , 𝑦𝑛−2
′
𝑦𝑛−3 = 𝑓 𝑥𝑛−3 , 𝑦𝑛−3 for 𝑛 ≥ 3
∗
We then substitute 𝑦𝑛+1 into Adams-Moulton corrector,
ℎ ′ ′ ′
𝑦𝑛+1 = 𝑦𝑛 + 9𝑦𝑛+1 + 19𝑦𝑛′ − 5𝑦𝑛−1 + 𝑦𝑛−2 (6)
24
′ ∗
𝑦𝑛+1 = 𝑓(𝑥𝑛+1 , 𝑦𝑛+1 )
Example 3.6.1
Use the Adams-Bashforth-Moulton method to obtain the approximate
value of 𝑦(1.5) for the solution of the initial-value problem with ℎ = 0.1
𝑦 ′ = 2𝑥𝑦, 𝑦 1 = 1.
Solution:
For step size of ℎ = 0.1, 𝑦(1.5) will be approximated by 𝑦5 .
We use the RK4 method with 𝑥0 = 1, 𝑦0 = 1, and ℎ = 0.1 to obtain
𝑦1 = 1.23367, 𝑦2 = 1.55270, 𝑦3 = 1.99369
Now, the identifications for
𝑥0 = 1, 𝑥1 = 1.1, 𝑥2 = 1.2, 𝑥3 = 1.3, 𝑓 𝑥, 𝑦 = 2𝑥𝑦
we find
𝑦0′ = 𝑓 𝑥0 , 𝑦0 = 2 1 1 = 2
𝑦1′ = 𝑓 𝑥1 , 𝑦1 = 2 1.1 1.23367 = 2.71407
𝑦2′ = 𝑓 𝑥2 , 𝑦2 = 2 1.2 1. 55270 = 3.72648
𝑦3′ = 𝑓 𝑥3 , 𝑦3 = 2 1.3 1.99369 = 5.18359
Example 3.6.1
Solution:
Foregoing values the predictor (5) will gives
0.1
𝑦4∗ = 𝑦3 + 55𝑦3′ − 59𝑦2′ + 37𝑦1′ − 9𝑦0′ = 2.60892
24
To use the corrector (6), we first need
𝑦4′ = 𝑓 𝑥4 , 𝑦4∗ = 2 1.4 2.60892 = 7.30498
Finally, (2) yields
0.1
𝑦4 = 𝑦3 + 9𝑦4′ + 19𝑦3′ − 5𝑦2′ + 𝑦1′ = 2.61167
24
′
𝒚𝟒 = 𝒇 𝒙𝟒 , 𝒚𝟒 = 𝟐 𝟏. 𝟒 𝟐. 𝟔𝟏𝟏𝟔𝟕 = 𝟕. 𝟑𝟏𝟐𝟔𝟔
∗
0.1
𝑦5 = 𝑦4 + 55𝑦4′ − 59𝑦3′ + 37𝑦2′ − 9𝑦1′ = 3.48590
24
𝑦5 = 𝑓 𝑥5 , 𝑦5∗ = 2 1.5 3.48590 = 10.45771
′
0.1
𝑦5 = 𝑦4 + 9𝑦5′ + 19𝒚′𝟒 − 5𝑦3′ + 𝑦2′ = 3.49028
24
School of Mathematical Sciences, Sunway University 54 MAT2034 Mathematical Methods
Multistep Methods
Example 3.6.1
0.1
Solution: 𝑦5 = 𝑦4 + 9𝑦5′ + 19𝒚′𝟒 − 5𝑦3′ + 𝑦2′ = 3.49028
24
n x(n) k1 k2 k3 k4 y(n) y*(n) y'(n) Actual value Absolute error Relative error
0 1.00 2.00000 2.3100 2.3426 2.7154 1.00000 2.00000 1.0000 0.00000 0.0000
1 1.10 2.71408 3.1496 3.1997 3.7287 1.23367 2.71408 1.2337 0.00000 0.0003
2 1.20 3.72647 4.3475 4.4252 5.1876 1.55270 3.72647 1.5527 0.00001 0.0008
3 1.30 5.18359 6.0827 6.2041 7.3195 1.99369 5.18359 1.9937 0.00003 0.0014
𝑑𝑦
+ 𝑝 𝑥 𝑦 = 𝑞(𝑥)
𝑑𝑥
is given by
𝜇 𝑥 𝑦 = ∫ 𝜇 𝑥 𝑞 𝑥 𝑑𝑥 + 𝐶
where 𝜇 𝑥 = 𝑒 ∫ 𝑝 𝑥 𝑑𝑥
is known as the integrating factor.
• Real life problems are often not linear and first order, so it will be
difficult to solve these problems analytically.
𝑥𝑖−1 𝑥𝑖 𝑥𝑖+1 𝑥
Note:
𝑑𝑦 ∆𝑦
The differential ≠ “the difference”. (1)
𝑑𝑥 ∆𝑥
𝑥𝑖−1 𝑥𝑖 𝑥𝑖+1 𝑥
𝑑𝑦 𝑦𝑖+1 − 𝑦𝑖
ቤ ≈ (2)
𝑦𝑖+1 𝑦(𝑥) 𝑑𝑥 𝑥=𝑥 ℎ
𝑖
𝑦𝑖
The derivative of the function at other values
𝑦𝑖−1 of the variable 𝑥 in the positive direction can
be expressed following equation (2) are
∆𝑥 ∆𝑥
𝑑𝑦 𝑦𝑖+2 − 𝑦𝑖+1
𝑥𝑖−1 𝑥𝑖 𝑥𝑖+1 𝑥 ቤ ≈
𝑑𝑥 𝑥=𝑥 +1 ℎ
𝑖
𝑑𝑦 𝑦𝑖+3 − 𝑦𝑖+2
ቤ ≈
𝑑𝑥 𝑥=𝑥 +2 ℎ
𝑖
and etc.
The second order derivative of the function at 𝑥 can be derived by the following
procedure:
𝑑𝑦 𝑑𝑦
ฬ − ฬ
2
𝑑 𝑦 𝑑 𝑑𝑦 𝑑𝑥 𝑥=𝑥 +1 𝑑𝑥 𝑥=𝑥
𝑖 𝑖
2 อ = อ = lim
𝑑𝑥 𝑑𝑥 𝑑𝑥 ∆𝑥→0 ∆𝑥
𝑥=𝑥𝑖 𝑥=𝑥𝑖
∆𝑦 ∆𝑦
∆𝑥 𝑥=𝑥 +1 ∆𝑥 ฬ𝑥=𝑥
ฬ −
𝑖 𝑖
≈
∆𝑥
𝑦𝑖+2 − 𝑦𝑖+1 𝑦𝑖+1 − 𝑦𝑖
−
= ℎ ℎ
ℎ
𝑦𝑖+2 − 2𝑦𝑖+1 + 𝑦𝑖
= (3)
ℎ2
∆𝑥 ∆𝑥
and the second order derivatives in the form:
𝑑2 𝑦 𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 𝑥𝑖−1 𝑥𝑖 𝑥𝑖+1 𝑥
อ ≈ (7)
𝑑𝑥 2 ℎ2
𝑥=𝑥𝑖
Suppose
𝑎 = 𝑥0 < 𝑥1 < ⋯ < 𝑥𝑛−1 < 𝑥𝑛 = 𝑏
If we let
𝑦𝑖 = 𝑦 𝑥𝑖 , 𝑃𝑖 = 𝑃 𝑥𝑖 , 𝑄𝑖 = 𝑄 𝑥𝑖 , 𝑓𝑖 = 𝑓(𝑥𝑖 )
𝑑2 𝑦 𝑑𝑦
and if and in (8)
𝑑𝑥 2 𝑑𝑥
ℎ ℎ
1 + 𝑃𝑖 𝑦𝑖+1 + −2 + 𝑄𝑖 ℎ2 𝑦𝑖 + 1 − 𝑃𝑖 𝑦𝑖−1 = ℎ2 𝑓𝑖 (10)
2 2
It enables us to approximate the solution 𝑦(𝑥) of (8) at the interior mesh points
𝑥1 , 𝑥2 , … , 𝑥𝑛−1 of the interval 𝑎, 𝑏 .
Bear in mind that we know 𝑦0 and 𝑦𝑛 , since these are the prescribed boundary
conditions
𝑦0 = 𝑦 𝑥0 = 𝑦 𝑎 = 𝛼 and 𝑦𝑛 = 𝑦 𝑥𝑛 = 𝑦 𝑏 = 𝛽.
Example 10.3.1
Use the difference equation (10) with 𝑛 = 4 to approximate the solution of the
boundary-value problem.
𝑦 ′′ − 4𝑦 = 0, 𝑦 0 = 0, 𝑦 1 = 5.
Solution:
𝑑2 𝑦 𝑑𝑦
+ 𝑃(𝑥) + 𝑄 𝑥 𝑦 = 𝑓 𝑥 , 𝑦 𝑎 = 𝛼, 𝑦 𝑏 = 𝛽
𝑑𝑥 2 𝑑𝑥
From (8), we have
𝑏−𝑎 1−0
𝑃 𝑥 = 0, 𝑄 𝑥 = −4, 𝑓 𝑥 = 0, ℎ = = = 0.25
𝑛 4
𝑥0 = 0, 𝑦0 = 0, 𝑥4 = 1 , 𝑦4 = 5.
ℎ ℎ
1 + 𝑃𝑖 𝑦𝑖+1 + −2 + 𝑄𝑖 ℎ2 𝑦𝑖 + 1 − 𝑃𝑖 𝑦𝑖−1 = ℎ2 𝑓𝑖
2 2
Then, we have
0.25 2
0.25
1+ (0) 𝑦𝑖+1 + −2 + −4 0.25 𝑦𝑖 + 1 − (0) 𝑦𝑖−1 = 0.25 2 (0)
2 2
Example 10.3.1
Use the difference equation (10) with 𝑛 = 4 to approximate the solution of the
boundary-value problem.
𝑦 ′′ − 4𝑦 = 0, 𝑦 0 = 0, 𝑦 1 = 5.
Solution:
0.25 0.25
1+ (0) 𝑦𝑖+1 + −2 + −4 0.25 2 𝑦𝑖 + 1 − (0) 𝑦𝑖−1 = 0.25 2 (0)
2 2
After simplify, we have
𝑦𝑖+1 − 2.25𝑦𝑖 + 𝑦𝑖−1 = 0
Since 𝑛 = 4, the interval [0,1] has 4 partitions with 𝑥0 = 0, 𝑥4 = 1 and interior points
𝑥𝑖 = 𝑥0 + 𝑖ℎ where 𝑖 = 1,2 and 3, that is
𝑥1 = 𝑥0 + 1ℎ = 0 + 0.25 = 0.25
𝑥2 = 𝑥0 + 2ℎ = 0 + 2(0.25) = 0.50
𝑥3 = 𝑥0 + 3ℎ = 0 + 3(0.25) = 0.75
Example 10.3.1
Use the difference equation (10) with 𝑛 = 4 to approximate the solution of the
boundary-value problem.
𝑦 ′′ − 4𝑦 = 0, 𝑦 0 = 0, 𝑦 1 = 5.
Solution:
Example 10.3.2
Use the difference equation (10) with 𝑛 = 10 to approximate the solution of the
boundary-value problem.
𝑦 ′′ + 3𝑦 ′ + 2𝑦 = 4𝑥 2 , 𝑦 1 = 1, 𝑦 2 = 6.
Solution:
𝑑2 𝑦 𝑑𝑦
+ 𝑃(𝑥) + 𝑄 𝑥 𝑦 = 𝑓 𝑥 , 𝑦 𝑎 = 𝛼, 𝑦 𝑏 = 𝛽
𝑑𝑥 2 𝑑𝑥
Example 10.3.2
Use the difference equation (10) with 𝑛 = 10 to approximate the solution of the
boundary-value problem.
𝑦 ′′ + 3𝑦 ′ + 2𝑦 = 4𝑥 2 , 𝑦 1 = 1, 𝑦 2 = 6.
Solution:
From 𝑛 = 10, the interior points with 𝑥𝑖 = 𝑥0 + 𝑖ℎ, 𝑖 = 1,2, … , 9 are 𝑥1 = 1.1,
𝑥2 = 1.2, 𝑥3 = 1.3, 𝑥4 = 1.4, 𝑥5 = 1.5, 𝑥6 = 1.6, 𝑥7 = 1.7, 𝑥8 = 1.8 and 𝑥9 = 1.9.
With 𝑖 = 1,2, … , 9 and 𝑦0 = 1 and 𝑦10 = 6, (10) yields a system of 9 equations and 9
unknowns:
Solution:
Example 10.3.2
1.15𝑦2 − 1.98𝑦1 = −0.8016
1.15𝑦3 − 1.98𝑦2 + 0.85𝑦1 = 0.0576
1.15𝑦4 − 1.98𝑦3 + 0.85𝑦2 = 0.0676
We can solve this large system
1.15𝑦5 − 1.98𝑦4 + 0.85𝑦3 = 0.0784
using Gaussian elimination or,
1.15𝑦6 − 1.98𝑦5 + 0.85𝑦4 = 0.0900
which relative ease, by means of
1.15𝑦7 − 1.98𝑦6 + 0.85𝑦5 = 0.1024
computer algebra system. The
1.15𝑦8 − 1.98𝑦7 + 0.85𝑦6 = 0.1156
results is found to be:
1.15𝑦9 − 1.98𝑦8 + 0.85𝑦7 = 0.1296
−1.98𝑦9 + 0.85𝑦8 = −6.7556
𝒏 1 2 3 4 5 6 7 8 9
𝑥𝑖 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
𝑦𝑖 2.4047 3.4432 4.2010 4.7469 2.1359 5.4124 5.6117 5.7620 5.8855