You are on page 1of 7

‫‪HW-1‬‬

‫‪439013770‬‬ ‫فهد حمود الحربي‬


‫‪439025197‬‬ ‫عبدالعزيز الوسيدي‬
‫‪438027406‬‬ ‫ياسر السلمي‬
‫‪439012449‬‬ ‫سلطان الدريويش‬
For the shown storage tank, suppose that the outflow is not constant but
rather depends on the depth. For this case, the differential equation for depth can
be written as:
1.5
dy Q α ( 1+ y )
=3 sin 2 (t )−
dx A A

3
m
For the parameter values are A=1200 m2 , Q=500 ,α =300 and initial condition y =
d
0. Use Euler’s method to solve for the depth y from t = 0 to t = 10 d.

a) With a step size of 1 d.


b) With a step size of 0.5 d.
c) Plot both the graphs on the same charts and find the approximate error ε a
of y at t = 5 d.

New value=old value+ slope × step¿ ¿


y new = y old + slope ×∆ t
1.5
α ( 1+ y old )
(Q
y new = y old + 3 sin 2 ( t old ) −
A A )t

a) Solve with a step size of 1 d:


 First iteration (t = 1):
1.5
α ( 1+ y old )
(Q
y new = y old + 3 sin2 ( t old ) −
A A )t

1.5
500 300 ( 1+0 )
y new =0+ 3 ( 1200
sin2 ( 0 ) −
1200 ) (1−0)

y new =−0.25
 Second iteration (t = 2):
1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin 2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+(−0.25) )
y new =(−0.25)+ 3 ( 1200
sin 2 ( 1 )−
1200 ) (2−1)

y new =0.472712

 Third iteration (t = 3):


1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin 2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+0.472712 )
y new =0.472712+ 3 ( 1200
sin2 ( 2 )−
1200 ) ( 3−2)

y new =1.059436

Step size = 1
Step size1.4 1
t y εa
1.2
0 0
1
1 -0.25 100
0.8 0.47271 152.8
2 0.6 2 9
1.05943 55.38 b) With a step size
0.4
3 6 1 of 0.5 d:
0.2 0.34546 206.6
4 9 7  First
0
0 2 4 6 8 10 12
0.67123 48.53 iteration (t =
-0.2
5 9 3
-0.4 1.28052 47.58 0.5):
6 9 1
147.6
7 0.51714 2
0.58950 12.27
8 5 6
1.31204
9 8 55.07
0.64545 103.2
10 9 7
1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin 2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+0 )
y new =0+ 3 ( 1200
sin 2 ( 0 ) −
1200 ) (0.5−0)

y new =−0.125

 Second iteration (t = 1):


1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+(−0.125))
y new =−0.125+ 3
1200(sin2 ( 0.5 )−
1200 ) (1−0.5)

y new =−0.0836554

 Third iteration (t = 1.5):


1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+ (−0.0836554 ) )
y new =−0.0836554+ 3(1200
sin2 ( 1 )−
1200 ) (1.5−1)

y new =0.2492431

 Fourth iteration (t = 2):


1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+0.2492431 )
(
y new =0.2492431+ 3
1200
sin 2 (1.5 )−
1200 ) ( 2−1.5)

y new =0.69658159

 fifth iteration (t = 2.5):


1.5
α ( 1+ y old )
Q
(
y new = y old + 3 sin2 ( t old ) −
A A )t∆

1.5
500 300 ( 1+0.69658159 )
y new =0.69658159+ 3 ( 1200
sin2 ( 2 )−
1200 ) (2.5−2)
Step
size 0.5
t y εa
y new =0.9371144
0 0
0.5 -0.125 100 Step size = 0.5
1.4-
0.08365 49.4
1 54
1.2 22
0.24924 133.
1
1.5 31 56
0.69658
0.8 64.2
2 159 19 c) Plot both the
0.93711
0.6 25.6
2.5 44 67 graphs on the
0.4
0.82395 13.7 same charts
3 986
0.2 33
and find the
0.52849 55.9
0
3.5 017 0 08 2 4 6 8 10 12 approximate
0.36918 43.1
-0.2 error ε aof y at t
4 261 51
0.52688 29.9 = 5 d.
4.5 775 31
 Approximate error ε a at t = 5 d (with step size = 1)
0.88827 40.6
5 421 84
1.13863 21.9
5.5 877 88
1.05881 7.53
6 028 95
0.73834 43.4
6.5 402 03
0.48077 53.5
7 417 74
0.52530 8.47
7.5 496 71
0.83973 37.4
8 231 44
1.13958 26.3
8.5 18 12
1.14686 0.63
9 628 52
0.85981 33.3
9.5 369 85
0.54630 57.3
10 341 88
y new − y old
ε a= | y new | ×100 %

ε a= |0.671239−0.345469
0.671239 |×100 %
ε a=48.533%

 Approximate error ε a at t = 5 d (with step size = 0.5)

y new − y old
ε a= | y new | ×100 %

ε a= |0.88827421−0.52688775
0.88827421 |×100 %
ε a=40.684 %
Both graphs
1.4

1.2

0.8

0.6

0.4

0.2

0
0 2 4 6 8 10 12

-0.2

Step size =1 Step size =0.5

You might also like