rk4 Complete Ques
rk4 Complete Ques
EXERCISE 2.6
Question no 9: Solve DE for stepsize 05, 0.1 and 1 find the value of y(3).
0. 2.
0.5 K1736.10701847076
50
1.0 K1.24950160714403 # 10
RK4 d (3)
1.5 Float -N
2.0 Float -N
2.5 Float -N
3.0 Float -N
3.5
3
2.5
0 1 2 3
t
> display curve, RK4ptplot ;
0
1 2 3
49 t
K2. # 10
49
K4. # 10
49
K6. # 10
49
K8. # 10
50
K1. # 10
50
K1.2 # 10
> FuncSol d dsolve IVP, numeric, stepsize = 0.5, method = classical rk4 , output
= listprocedure ;
FuncSol d t = proc t ... end proc, y t = proc t ... end proc (5)
> y2 d eval y t , FuncSol
y2 d proc t ... end proc (6)
> seq y2 i , i = 0 ..3
(7)
50
2., K1.24950160714403 # 10 , Float -N , Float -N (7)
10
> actualy2 d t→evalf K15 t
2C3 e
10
actualy2 d t ↦ evalf K15$t
(8)
2 C 3$e
(9)
> seq actualy2 i , i = 0 ..3
2., 4.999997705, 5.000000000, 5.000000000 (10)
0. 2.
RK4 d 8 (14)
1.0 K4.40535355 # 10
141
2.0 K1.17489744602301 # 10
3.0 Float -N
140
K4. # 10
140
K6. # 10
140
K8. # 10
141
K1. # 10
3.5
3
2.5
0 1 2 3
t
> display curve, RK4ptplot ;
0
1 2 3
140 t
K2. # 10
140
K4. # 10
140
K6. # 10
140
K8. # 10
141
K1. # 10
> FuncSol d dsolve IVP, numeric, stepsize = 1, method = classical rk4 , output = listprocedure ;
FuncSol d t = proc t ... end proc, y t = proc t ... end proc (16)
> y2 d eval y t , FuncSol
y2 d proc t ... end proc (17)
> seq y2 i , i = 0 ..3
(18)
8 141
2., K4.40535355 # 10 , K1.17489744602301 # 10 , Float -N (18)
10
> actualy2 d t→evalf K15 t
2C3 e
10
actualy2 d t ↦ evalf K15$t
(19)
2 C 3$e
(20)
> seq actualy2 i , i = 0 ..3
2., 4.999997705, 5.000000000, 5.000000000 (21)
>
>
> with plots :
> IVP d diff y t , t = y t $ 15 K 3$y t , y 0 = 2 ;
d
IVP d y t = y t 15 K 3 y t , y 0 = 2 (23)
dt
> Sol d dsolve IVP, y t ;
10
Sol d y t = K15 t
(24)
2C3 e
> RK4 d dsolve IVP, numeric, method = classical rk4 , output = Array 0.0, 0.1, 0.2, 0.3, 0.4,
0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5,
2.6, 2.7, 2.8, 2.9, 3.0 , stepsize = 0.1
t y t
0. 2.
0.1 3.74179198562833
0.2 4.62742202256609
0.3 4.89643285677944
0.4 4.97154632700253
RK4 d (25)
0.5 4.99220927100966
0.6 4.99786893395888
0.7 4.99941722747814
0.8 4.99984064371199
0.9 4.99995642568395
« «
31 # 2 Matrix
2
0 1 2 3
> curve d plot rhs Sol , t = 0 ..3, thickness = 3 ;
5
4.5
4
3.5
3
2.5
0 1 2 3
t
> display curve, RK4ptplot ;
5
2
0 1 2 3
t
> FuncSol d dsolve IVP, numeric, stepsize = 0.1, method = classical rk4 , output
= listprocedure ;
FuncSol d t = proc t ... end proc, y t = proc t ... end proc (27)
> y2 d eval y t , FuncSol
y2 d proc t ... end proc (28)
> seq y2 i , i = 0 ..30
2., 4.99998808512320, 4.99999999997216, 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., (29)
5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5.
10
> actualy2 d t→evalf K15 t
2C3 e
10
actualy2 d t ↦ evalf K15$t
(30)
2 C 3$e
(31)
> seq actualy2 i , i = 0 ..30
2., 4.999997705, 5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000, (32)
5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000,
5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000,
5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000,
5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000, 5.000000000
>
>
>