Upload
ahmed-awad
View
23
Download
12
Embed Size (px)
DESCRIPTION
Numerical Solutions1. (a) Use Euler's method with h = 0.25 to solve the following ODE between x = 0 and x = 1 ( if the initial condition is y (0) = 1.0 ) (b) Use the Heun's method with h = 0.25 to solve the previous ODE between x = 0 and x = 1 (c) Use the Midpoint method with h = 0.25 to solve the previous ODE between x = 0 and x = 12. (a) Use Euler's method with h = 0.5 and h = 0.25 to solve: ( initial condition is y (0) = 1.0 ) = x 2 y - 1.2 y (b) Use the Heun's method with h = 0.5 to solve the previous ODE. (c) Use the Midpoint method with h = 0.5 and h = 0.25 to solve the previous ODE.3. Given that: = 30 [ sin (t) - y ] + 3 cos (t) with y (0) = 0. Use the implicit Euler to obtain a solution from t=0 to 4 using a step size of 0.4.4. Given that: = 999 y + 1999 z & = - 1000 y – 2000 z with y (0) = z (0) = 1. Obtain a solution between t=0 and 0.25 using a step size of 0.05 with the explicit Euler method. Repeat your solution using implicit Euler method. 5. The steady state heat balance for a rod is represented by: - 0.1 . T = 0.0 A B x T (A) =200 T (B) =100 where T is the temperature. Use the Finite difference method to solve the previous ODE for a bar length of 10 m. Obtain the solution every 1.0 m.6. Use the finite difference method to obtain a solution for the following ODE between x=0 and x=10 with step size ∆x=2.0: ( The boundary conditions are y (0)=5 and y (10)=8 ) - 2 - y + x = 0.0
Citation preview
Assignment 5
Presented to: Prof. Taher G. Abu-El-Yazied
Prof. Niveen M. Badra
Presented by: Ahmed Hassan Ibrahim
1. (a) Use Euler's method with h = 0.25 to solve the following ODE between x = 0 and x = 1
(If the initial condition is y (0) = 1.0)
y ) x 1 ( xd
y d
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖)ℎ
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑦𝑖+1
0 0 1 1 1.25
1 0.25 1.25 1.397542 1.599386
2 0.5 1.599386 1.897002 2.073636
3 0.75 2.073636 2.520022 2.703642
4 1 2.703642 3.288551 3.525779
𝑦4 = 2.703642
(b) Use the Heun's method with h = 0.25 to solve the previous ODE between x = 0 and x = 1
𝑦𝑖+1° = 𝑦
𝑖+ 𝑓(𝑥𝑖, 𝑦
𝑖)ℎ
𝑦𝑖+1 = 𝑦𝑖 +𝑓(𝑥𝑖 , 𝑦𝑖) + 𝑓(𝑥𝑖+1, 𝑦𝑖+1
°)
2ℎ
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑦𝑖+1° 𝑥𝑖+1 𝑓(𝑥𝑖+1, 𝑦𝑖+1
°) 𝑦𝑖+1
0 0 1 1 1.25 0.25 1.39754249 1.299693
1 0.25 1.299693 1.425051 1.655956 0.5 1.93025904 1.719107
2 0.5 1.719107 1.966721 2.210787 0.75 2.60202503 2.2902
3 0.75 2.2902 2.648346 2.952286 1 3.43644366 3.050798
4 1 3.050798 3.493307 3.924125 1.25 4.45711609 4.044601
𝑦4 = 3.050798
(c) Use the Midpoint method with h = 0.25 to solve the previous ODE between x = 0 and x = 1
𝑥𝑖+1/2 = 𝑥𝑖 +ℎ
2
𝑦𝑖+1/2 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖)ℎ
2
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥+1/2𝑖 , 𝑦𝑖+1/2)ℎ
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑥𝑖+1/2 𝑦𝑖+1/2 𝑓(𝑥+1/2𝑖 , 𝑦𝑖+1/2) 𝑦𝑖+1
0 0 1 1 0.125 1.125 1.19324269 1.298311
1 0.25 1.298311 1.424293 0.375 1.47634729 1.6706942 1.715984
2 0.5 1.715984 1.964934 0.625 1.96160094 2.27592893 2.284966
3 0.75 2.284966 2.645318 0.875 2.61563126 3.03242125 3.043072
4 1 3.043072 3.48888 1.125 3.47918183 3.96367007 4.033989
𝑦4 = 3.050798
2. (a) Use Euler's method with h = 0.5 and h = 0.25 to solve: ( initial condition is y (0) = 1.0 )
xd
y d = x 2 y - 1.2 y
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖)ℎ
h 0.5
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑦𝑖+1
0 0 1 -1.2 0.4
1 0.5 0.4 -0.38 0.21
2 1 0.21 -0.042 0.189
𝑦2 = 0.21
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑦𝑖+1
0 0 1 -1.2 0.7
1 0.25 0.7 -0.79625 0.500938
2 0.5 0.500938 -0.47589 0.381965
3 0.75 0.381965 -0.2435 0.321089
4 1 0.321089 -0.06422 0.305035
𝑦4 = 0.321089
(b) Use the Heun's method with h = 0.5 to solve the previous ODE.
𝑦𝑖+1° = 𝑦
𝑖+ 𝑓(𝑥𝑖, 𝑦
𝑖)ℎ
𝑦𝑖+1 = 𝑦𝑖 +𝑓(𝑥𝑖 , 𝑦𝑖) + 𝑓(𝑥𝑖+1, 𝑦𝑖+1
°)
2ℎ
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑦𝑖+1° 𝑥𝑖+1 𝑓(𝑥𝑖+1, 𝑦𝑖+1
°) 𝑦𝑖+1
0 0 1 -1.2 0.4 0.5 -0.38 0.605
1 0.5 0.605 -0.57475 0.317625 1 -0.063525 0.445431
2 1 0.445431 -0.08909 0.400888 1.5 0.42093253 0.528393
𝑦2 = 0.445431
(c) Use the Midpoint method with h = 0.5 and h = 0.25 to solve the previous ODE.
𝑥𝑖+1/2 = 𝑥𝑖 +ℎ
2
𝑦𝑖+1/2 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖)ℎ
2
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥+1/2𝑖 , 𝑦𝑖+1/2)ℎ
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑥𝑖+1/2 𝑦𝑖+1/2 𝑓(𝑥+1/2𝑖 , 𝑦𝑖+1/2) 𝑦𝑖+1
0 0 1 -1.2 0.125 0.85 -1.00671875 0.74832
1 0.25 0.74832 -0.85121 0.375 0.64191852 -0.68003243 0.578312
2 0.5 0.578312 -0.5494 0.625 0.50963763 -0.41248796 0.47519
3 0.75 0.47519 -0.30293 0.875 0.4373235 -0.18996239 0.4277
𝑦4 = 0.47519
h 0.25
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑥𝑖+1/2 𝑦𝑖+1/2 𝑓(𝑥+1/2𝑖 , 𝑦𝑖+1/2) 𝑦𝑖+1
0 0 1 -1.2 0.125 0.7 -0.8290625 0.585469
1 0.5 0.585469 -0.5562 0.625 0.44641992 -0.36132112 0.404808
2 1 0.404808 -0.08096 1.125 0.38456778 0.02523726 0.417427
𝑦2 = 0.404808
3. Given that:
td
y d = 30 [sin (t) - y] + 3 cos (t)
With y (0) = 0. Use the implicit Euler to obtain a solution from t=0 to 4 using a step size of 0.4.
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖)ℎ
h 0.5
i 𝑥𝑖 𝑦𝑖 𝑓(𝑥𝑖 , 𝑦𝑖) 𝑦𝑖+1
0 0 1 -27 -1.7
1 0.1 -1.7 56.98001 3.998001
2 0.2 3.998001 -111.04 -7.10598
3 0.3 -7.10598 224.9109 15.38511
4 0.4 15.38511 -447.108 -29.3256
𝑦4 = 15.38511
4. Given that:
td
y d = 999 y + 1999 z &
td
z d = - 1000 y – 2000 z
With y (0) = z (0) = 1. Obtain a solution between t=0 and 0.25 using a step size of 0.05 with the explicit
Euler method. Repeat your solution using implicit Euler method.
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖)ℎ
Implicit
𝑓𝑖𝑟𝑠𝑡 𝑒𝑞𝑎𝑢𝑡𝑖𝑜𝑛 ∶ y𝑖+1 = 𝑦𝑖 + (999 y𝑖+1 + 1999 z𝑖+1)(0.05)
𝑠𝑒𝑐𝑜𝑛𝑑 𝑒𝑞𝑎𝑢𝑡𝑖𝑜𝑛 ∶ 𝑧𝑖+1 = 𝑧𝑖 + (−1000 y𝑖+1 − 2000 z𝑖+1)(0.05)
𝑓𝑟𝑜𝑚 𝑓𝑖𝑟𝑠𝑡 𝑒𝑞𝑎𝑢𝑡𝑖𝑜𝑛: 𝑦𝑖 = −48.95 y𝑖+1 − 99.95 z𝑖+1
𝑓𝑟𝑜𝑚 𝑠𝑒𝑐𝑜𝑛𝑑 𝑒𝑞𝑎𝑢𝑡𝑖𝑜𝑛: 𝑧𝑖 = 50 y𝑖+1 + 101 z𝑖+1
y𝑖+1 = 1.88607 𝑦𝑖 + 1.86648 𝑧𝑖
z𝑖+1 = 0.9337 𝑦𝑖 − 0.9141 𝑧𝑖
h 0.5
i 𝑥𝑖 𝑦𝑖 𝑦𝑖+1 𝑧𝑖+1
0 1 1 3.75255 -1.8478
0.05 3.75255 -1.8478 3.62869 -1.81468
0.1 3.62869 -1.81468 3.456896 -1.72931
0.15 3.456896 -1.72931 3.292231 -1.64694
0.2 3.292231 -1.64694 3.135389 -1.56848
0.25 3.135389 -1.56848 2.986019 -1.49376
𝑦5 = −1.56848
5. The steady state heat balance for a rod is represented by:
x
d2
2
d
T - 0.1 T = 0.0
A B x
T (A) =200 T (B) =100
Where T is the temperature. Use the Finite difference method to solve the previous ODE for a bar
length of 10 m. Obtain the solution every 1.0 m.
𝑑2𝑦
𝑑𝑥2|
𝑖
=𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1
(∆𝑥)2
𝑑 𝑦
𝑑𝑥 |
𝑖
=𝑦𝑖+1 − 𝑦𝑖−1
2∆𝑥
𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1
(∆𝑥)2− 𝟎. 𝟏𝑻 = 𝟎
𝑇𝑖+1 − 2.1𝑇𝑖 + 𝑇𝑖−1 = 𝟎
i t1 t2 t3 t4 t5 t6 t7 t8 t9 =
1 -2.1 1 0 0 0 0 0 0 0 -200
2 1 -2.1 1 0 0 0 0 0 0 0
3 0 1 -2.1 1 0 0 0 0 0 0
4 0 0 1 -2.1 1 0 0 0 0 0
5 0 0 0 1 -2.1 1 0 0 0 0
6 0 0 0 0 1 -2.1 1 0 0 0
7 0 0 0 0 0 1 -2.1 1 0 0
8 0 0 0 0 0 0 1 -2.1 1 0
9 0 0 0 0 0 0 0 1 -2.1 -100
6. Use the finite difference method to obtain a solution for the following ODE between x=0 and x=10
with step size ∆x=2.0: ( The boundary conditions are y (0)=5 and y (10)=8 )
x
d2
2
d
y - 2
xd
y d - y + x = 0.0
𝑑2𝑦
𝑑𝑥2|
𝑖
=𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1
(∆𝑥)2
𝑑 𝑦
𝑑𝑥 |
𝑖
=𝑦𝑖+1 − 𝑦𝑖−1
2∆𝑥
𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1
(∆𝑥)2− 2
𝑦𝑖+1 − 𝑦𝑖−1
2∆𝑥− 𝑦𝑖 + 𝑥𝑖 = 0
𝑦𝑖+1 − 2𝑦𝑖 + 𝑦𝑖−1 − ∆𝑥(𝑦𝑖+1 − 𝑦𝑖−1) + (∆𝑥)2(−𝑦𝑖 + 𝑥𝑖) = 0
−1𝑦𝑖+1 − 6𝑦𝑖 + 3𝑦𝑖−1 + 4𝑥𝑖 = 0
i xi y1 y2 y3 y4 =
1 2 -6 -1 0 0 -23
2 4 3 -6 -1 0 -16
3 6 0 3 -6 -1 -24
4 8 0 0 3 -6 -24
(𝐀|𝐈) = (𝐈|𝐀−𝟏)
(
−6 −1 03 −6 −10 3 −6
00
−10 0 3 −6
) (
𝑦1
𝑦2𝑦3
𝑦4
) = (
−23−16−24−24
)
[𝐴][𝑌] = [𝐶] ⟹ [𝑌] = [𝐴]−1 [𝐶]
(
𝑦1
𝑦2𝑦3
𝑦4
) = (
−0.15469611 0.023941 −0.00368
−0.07182321 −0.14365 0.022099
−0.03314916 −0.0663 −0.14365
0.000614
−0.00368
0.023941−0.01657458 −0.03315 −0.07182 −0.1547
) (
−23−16−24−24
)
(
𝑦1
𝑦2𝑦3
𝑦4
) = (
3.248539
3.5082784.696247
6.348095
)