Maple Last Assignm
Maple Last Assignm
MAPLE ASSIGNMENT
Name: ASRA AYUB
AG: 2022-AG-953
Decay Model
> ode1 d diff Q t , t =Kk$Q t ; #kO0
d
ode1 d Q t = Kk Q t (1)
dt
> dsolve ode1 ;
Kk t
Q t = _C1 e (2)
Growth Model
> ode2 d diff Q t , t =Kk$Q t ; #k!0
d
ode2 d Q t = Kk Q t (3)
dt
> dsolve ode2 ;
Kk t
Q t = _C1 e (4)
Newton’s Law of Cooling
> ode3 d diff T t , t = k$ T t K T 0 ;
d
ode3 d T t = k T t K T0 (5)
dt
> dsolve ode3 ;
kt
T t = T0 C e _C1 (6)
Chemical Mixture
> ode d diff A t , t = R input K R out ;
d
ode d A t = Rinput K Rout (7)
dt
> dsolve ode ;
A t = Rinput K Rout t C _C1 (8)
k K a$a$ 2$g$h t
> ode9 d diff h t , t = ;
A
d kKa a 2 gh t
ode9 d h t = (18)
dt A
> dsolve ode9 ;
aa gh t 2
2 2 2 A k arctanh
A k ln 2 a a g h t K k A 2 gh t k
tC 2
C K 2
(19)
2
2a a g aag 2
a a g
C _C1 = 0
2.3 Slope Fields and Qualitative Assessments of Autonomous First-Order ODEs
EXERCISE:
Question 1
> restart;
> with DEtools :
> SlopeField1 d diff y x , x = y x ;
d
SlopeField1 d y x =y x (20)
dx
> DEplot SlopeField1, y x , x = 0 ..8, y = 0 ..10, 0, 2 , 0, 4 , linecolor = brown ;
10
6
yx
1 2 3 4 5 6 7 8
x
>
> SlopeField2 d diff y x , x = x;
d
SlopeField2 d y x =x (21)
dx
> DEplot SlopeField2, y x , x = 0 ..5, y = 0 ..8, 1, 5 , 3, 4 , linecolor = brown ;
8
7
6
5
yx 4
3
2
1
1 2 3 4 5
x
>
> SlopeField3 d diff y x , x = x C y x ;
d
SlopeField3 d y x = xCy x (22)
dx
> DEplot SlopeField3, y x , x = 0 ..5, y = 0 ..6, 0, 3 , 3, 4 , linecolor = brown ;
6
yx 3
1 2 3 4 5
x
>
> SlopeField4 d diff y x , x = x K y x ;
d
SlopeField4 d y x = xKy x (23)
dx
> DEplot SlopeField4, y x , x = 0 ..5, y = 0 ..6, 0, 3 , 3, 4 , linecolor = magenta ;
6
yx 3
1 2 3 4 5
x
>
> SlopeField5 d diff y x , x = x * y x ;
d
SlopeField5 d y x =xy x (24)
dx
> DEplot SlopeField5, y x , x = 0 ..5, y = 0 ..6, 0, 3 , 3, 4 , linecolor = brown ;
6
4
yx 3
1 2 3 4 5
x
>
1
> SlopeField6 d diff y x , x = ;
y x
d 1
SlopeField6 d y x = (25)
dx y x
> DEplot SlopeField6, y x , x = 0 ..8, y = 0 ..6, 0, 5 , 1, 3 , linecolor = brown ;
6
4
yx 3
1 2 3 4 5 6 7 8
x
>
Question 2:
> #a. with DEtools :
> ode d diff y x , x = y x C 2 $ y x K3
d
ode d y x = y x C2 y x K3 (26)
dx
> sol d dsolve ode, y x
5x
3 C 2 e _C1
sol d y x = K 5x
(27)
e _C1 K 1
> sol;
(28)
5x
3 C 2 e _C1
y x =K 5x
(28)
e _C1 K 1
> DEplot ode, y x , x = K2 ..2, y = 0 ..2
2
1.5
yx 1
0.5
K2 K1 0 1 2
x
> second_derivative d diff sol, x, x ;
2 5x 5x 2 2
d 50 e _C1 100 e _C1
second_derivative d 2
y x =K 5x
C 2
(29)
dx e _C1 K 1 5x
e _C1 K 1
5x 5x 2 2 5x 5x
50 3 C 2 e _C1 e _C1 25 3 C 2 e _C1 e _C1
K 3
C 2
5x 5x
e _C1 K 1 e _C1 K 1
> # Determine the concavity based on the sign of the second derivative
if is inequal second_derivative O 0, x = 1 ..10 then
print "The solution is concave up." ;
else
print "The concavity is not determined." ;
end if;
"The concavity is not determined." (30)
>
b:
2
> odeb d diff y x , x = y x K 4
d 2
odeb d y x =y x K4 (31)
dx
> sol d dsolve odeb, y x
4x
2 e _C1 C 1
sol d y x = K 4x
(32)
K1 C e _C1
> second_derivative d diff sol, x, x ;
(33)
2 4x 4x 2 2
d 32 e _C1 64 e _C1
second_derivative d 2
y x =K 4x
C 2
(33)
dx K1 C e _C1 4x
K1 C e _C1
4x 4x 2 2 4x 4x
64 e _C1 C 1 e _C1 32 e _C1 C 1 e _C1
K 3
C 2
4x 4x
K1 C e _C1 K1 C e _C1
> if is inequal second_derivative O 0, x then
print "The solution is concave up." ;
else
print "The concavity is not determined." ;
end if;
"The concavity is not determined." (34)
> if is inequal second_derivative ! 0, x then
print "The solution is concave down." ; else
print "The concavity is not determined." ;
end if;
d
ode d y x Cy x =x
dx
Kx
sol d y x = x K 1 C e _C1
Kx
y x = x K 1 C e _C1
point
point d x = 1
d Kx
slope_at_point d y x x = 1 K e _C1
dx
d Kx
y x x = 1 K e _C1 (36)
dx
> restart;
# Define the differential equation
ode d diff y x , x, x C 2 * diff y x , x C y x = x^2;
2
d d 2
ode d 2
y x C2 y x Cy x =x
dx dx
Kx Kx 2
sol d y x = e _C2 C e x _C1 C x K 4 x C 6
Kx Kx 2
y x = e _C2 C e x _C1 C x K 4 x C 6
2
d Kx Kx Kx
second_derivative d 2
y x = e _C2 C e x _C1 K 2 _C1 e C 2
dx
2
d Kx Kx Kx
2
y x = e _C2 C e x _C1 K 2 _C1 e C 2
dx
Error, invalid input: solve expects its 1st argument, eqs, to be
of type {`and`, `not`, `or`, algebraic, relation(algebraic),
{list, set}({`and`, `not`, `or`, algebraic, relation(algebraic)})}
, but received (diff(diff(y(x),x),x) = exp(-x)*_C2+exp(-x)*x*_C1
-2*_C1*exp(-x)+2) = 0
inflection_points (37)
> restart;
d
ode d y x Cy x =x
dx
Kx
sol d y x = x K 1 C e _C1
Kx
y x = x K 1 C e _C1
d Kx
slope d y x = 1 K e _C1
dx
d Kx
y x = 1 K e _C1 (38)
dx
> _C1 d 5;
slope;
_C1 d 5
d Kx
y x =1K5 e (39)
dx
Error, (in plot) unexpected options: [diff(y(x),x)+y(x) = x, y(x)]
> with plots :
> plot 1 K 5$ exp Kx , x = 0 ..10
1
0
2 4 6 8 10
x
K1
K2
K3
1.5
yx 1
0.5
K2 K1 0 1 2
x
> DEplot 1 K exp Kx $C1, y x , x = K2 ..2, y = 0 ..2
Error, (in DEtools/DEplot/CheckDE) derivatives must be given
explicitly
>
2.6
EXERCISE :
> with plots :
> IVP d diff y t , t = y t C t, y 2 =0 ;
d
IVP d y t = y t C t, y 2 = 0 (40)
dt
> Soln d dsolve IVP, y t ;
(41)
t
3e
Soln d y t = Kt K 1 C 2
(41)
e
> plot rhs Soln , t = 0 ..3, thickness = 3 ;
4
0
1 2 3
t
>
> NumericSoln d dsolve IVP, numeric, stepsize = 0.1, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0
t y t
0. K0.635270036228292
0.5 K0.882326603716053
1.0 K0.953964679700000
NumericSoln d (42)
1.5 K0.728530000000000
2.0 0.
2.5 1.33153000000000
3.0 3.78122738030000
> FunctionSoln d dsolve IVP, numeric, stepsize = 0.1, method = classical foreuler , output
= listprocedure ;
FunctionSoln d t = proc t ... end proc, y t = proc t ... end proc (43)
> fy2 d eval y t , FunctionSoln
fy2 d proc t ... end proc (44)
> seq fy2 i , i = 0 ..3 ;
K0.635270036228292, K0.953964679700000, 0., 3.78122738030000 (45)
t
3e
> actual_y2 d t → evalf Kt K 1 C 2
;
e
t
3$e
actual_y2 d t ↦ evalf Kt K 1 C 2
(46)
e
> seq actual_y2 i , i = 0 ..3 ;
K0.5939941504, K0.896361677, 0., 4.154845484 (47)
> Array t, Numerical_y t , Actual_y t , P ercent_Error , seq i, fy2 i , evalf actual_y2 i ,
evalf 100 , abs fy2 i Kactual_y2 i / actualy2 i , i = 0 ..3 ;
t Numerical_y t Actual_y t P ercent_Error
4.12758858282920
0 K0.635270036228292 K0.5939941504
actualy2 0
5.76030026999996
1 K0.953964679700000 K0.896361677 (48)
actualy2 1
2 0. 0. 0.
37.3618103700004
3 3.78122738030000 4.154845484
actualy2 3
> NumericSoln d dsolve IVP, numeric, stepsize = 0.05, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0
t y t
0. K0.614463530304690
0.5 K0.856083708171187
1.0 K0.924542232774373
NumericSoln d (49)
1.5 K0.703789182284863
2.0 0.
2.5 1.38668388033233
3.0 3.95989311543328
> FunctionSoln d dsolve IVP, numeric, stepsize = 0.05, method = classical foreuler , output
= listprocedure ;
FunctionSoln d t = proc t ... end proc, y t = proc t ... end proc (50)
> fy2 d eval y t , FunctionSoln
fy2 d proc t ... end proc (51)
> seq fy2 i , i = 0 ..3 ;
K0.614463530304690, K0.924542232774373, 0., 3.95989311543328 (52)
t
3e
> actual_y2 d t → evalf Kt K 1 C 2
;
e
t
3$e
actual_y2 d t ↦ evalf Kt K 1 C 2
(53)
e
> seq actual_y2 i , i = 0 ..3 ;
(54)
K0.5939941504, K0.896361677, 0., 4.154845484 (54)
> Array t, Numerical_y t , Actual_y t , P ercent_Error , seq i, fy2 i , evalf actual_y2 i ,
evalf 100 , abs fy2 i Kactual_y2 i / actualy2 i , i = 0 ..3 ;
t Numerical_y t Actual_y t P ercent_Error
2.04693799046897
0 K0.614463530304690 K0.5939941504
actualy2 0
2.81805557743728
1 K0.924542232774373 K0.896361677 (55)
actualy2 1
2 0. 0. 0.
19.4952368566719
3 3.95989311543328 4.154845484
actualy2 3
> NumericSoln d dsolve IVP, numeric, stepsize = 0.01, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0
t y t
0. K0.598060975426114
0.5 K0.835644638283416
1.0 K0.901902976180311
NumericSoln d (56)
1.5 K0.684981798587390
2.0 0.
2.5 1.43389546553168
3.0 4.11444148826471
> FunctionSoln d dsolve IVP, numeric, stepsize = 0.01, method = classical foreuler , output
= listprocedure ;
FunctionSoln d t = proc t ... end proc, y t = proc t ... end proc (57)
> fy2 d eval y t , FunctionSoln
fy2 d proc t ... end proc (58)
> seq fy2 i , i = 0 ..3 ;
K0.598060975426114, K0.901902976180311, 0., 4.11444148826471 (59)
t
3e
> actual_y2 d t → evalf Kt K 1 C 2
;
e
t
3$e
actual_y2 d t ↦ evalf Kt K 1 C 2
(60)
e
> seq actual_y2 i , i = 0 ..3 ;
K0.5939941504, K0.896361677, 0., 4.154845484 (61)
> Array t, Numerical_y t , Actual_y t , P ercent_Error , seq i, fy2 i , evalf actual_y2 i ,
evalf 100 , abs fy2 i Kactual_y2 i / actualy2 i , i = 0 ..3 ;
t Numerical_y t Actual_y t P ercent_Error
0.406682502611433
0 K0.598060975426114 K0.5939941504
actualy2 0
0.554129918031132
1 K0.901902976180311 K0.896361677 (62)
actualy2 1
2 0. 0. 0.
4.04039957352884
3 4.11444148826471 4.154845484
actualy2 3
# Question 2
> restart;
> with plots :
> IVP d diff y t , t = y t C 1, y 0 = 1 ;
d
IVP d y t = y t C 1, y 0 = 1 (63)
dt
> Soln d dsolve IVP, y t ;
t
Soln d y t = K1 C 2 e (64)
> plot rhs Soln , t = 0 ..0.5, thickness = 3 ;
2.2
2.0
1.8
1.6
1.4
1.2
(65)
t y t
0. 1.
0.5 2.12500000000000
1.0 3.88281250000000
NumericSoln d (65)
1.5 6.62939453125000
2.0 10.9209289550781
2.5 17.6264514923096
3.0 28.1038304567337
> FunctionSoln d dsolve IVP, numeric, stepsize = 1, method = classical foreuler , output
= listprocedure ;
FunctionSoln d t = proc t ... end proc, y t = proc t ... end proc (66)
> fy2 d eval y t , FunctionSoln
fy2 d proc t ... end proc (67)
> seq fy2 i , i = 3 ;
15. (68)
t
3e
> actual_y2 d t → evalf Kt K 1 C 2
;
e
t
3$e
actual_y2 d t ↦ evalf Kt K 1 C 2
(69)
e
> seq actual_y2 i , i = 0 ..3 ;
K0.5939941504, K0.896361677, 0., 4.154845484 (70)
> Array t, Numerical_y t , Actual_y t , P ercent_Error , seq i, fy2 i , evalf actual_y2 i ,
evalf 100 , abs fy2 i Kactual_y2 i / actualy2 i , i = 0 ..3 ;
t Numerical_y t Actual_y t P ercent_Error
159.3994150
0 1. K0.5939941504
actualy2 0
389.636167700000
1 3. K0.896361677
actualy2 1 (71)
700.
2 7. 0.
actualy2 2
1084.51545160000
3 15. 4.154845484
actualy2 3
> NumericSoln d dsolve IVP, numeric, stepsize = 0.25, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 ;
t y t
0. 1.
0.5 2.12500000000000
1.0 3.88281250000000
NumericSoln d (72)
1.5 6.62939453125000
2.0 10.9209289550781
2.5 17.6264514923096
3.0 28.1038304567337
> NumericSoln d dsolve IVP, numeric, stepsize = 0.1, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0
t y t
0. 1.
0.5 2.22102000000000
1.0 4.18748492020000
NumericSoln d (73)
1.5 7.35449633883130
2.0 12.4549998986512
2.5 20.6694118867767
3.0 33.8988045377728
> NumericSoln d dsolve IVP, numeric, stepsize = 0.05, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0
t y t
0. 1.
0.5 2.25778925355488
1.0 4.30659541028884
NumericSoln d (74)
1.5 7.64388475030132
2.0 13.0799774242493
2.5 21.9347995715074
3.0 36.3583717882460
# Question 3
> restart;
> with plots :
> IVP d diff v t , t = 32 * 6 * v t , v 0 = 0 ;
(75)
d
IVP d v t = 192 v t , v 0 = 0 (75)
dt
> NumericSoln d dsolve IVP, numeric, stepsize = 0.05, method = classical foreuler , output
= Array 0., 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 ;
t v t
0. 0.
0.5 0.
1.0 0.
NumericSoln d (76)
1.5 0.
2.0 0.
2.5 0.
3.0 0.
# Question 4
> restart;
> with plots :
> IVP d diff y t , t = y t C 1, y 0 = 1 ;
d
IVP d y t = y t C 1, y 0 = 1 (77)
dt
> Soln d dsolve IVP, y t ;
t
Soln d y t = K1 C 2 e (78)
> IEMSoln d dsolve IVP, numeric, method = classical heunform , output = Array 0., 0.5, 1.0,
1.5, 2.0, 2.5, 3.0 , stepsize = 0.25 ;
t y t
0. 1.
0.5 2.28320312500000
1.0 4.38971138000488
IEMSoln d (79)
1.5 7.84775862284005
2.0 13.5244943798771
2.5 22.8434326685287
3.0 38.1414163240202
> IEMFcnSoln d dsolve IVP, numeric, stepsize = 1, method = classical heunform , output
= listprocedure ;
IEMFcnSoln d t = proc t ... end proc, y t = proc t ... end proc (80)
> IEMy2 d eval y t , IEMFcnSoln ;
(81)
IEMy2 d proc t ... end proc (81)
> seq actual_y2 i , i = 0 ..3 ;
actual_y2 0 , actual_y2 1 , actual_y2 2 , actual_y2 3 (82)
> Array t, Numerical_y t , Actual_y t , P ercent_Error , seq i, IEMy2 i ,
evalf actual_y2 i , evalf 100 , abs IEMy2 i Kactual_y2 i / actualy2 i , i = 0 ..3
;
t Numerical_y t Actual_y t P ercent_Error
100. K1. C actual_y2 0
0 1. actual_y2 0
actualy2 0
100. K4. C actual_y2 1
1 4. actual_y2 1
actualy2 1 (83)
100. K11.5000000000000 C actual_y2 2
2 11.5000000000000 actual_y2 2
actualy2 2
100. K30.2500000000000 C actual_y2 3
3 30.2500000000000 actual_y2 3
actualy2 3
>
>
>
>
>
>