Janmjay Kumar (6037)
Janmjay Kumar (6037)
Janmjay Kumar (6037)
Sem - 2nd
Q .2 Solve dy dx - 3 1 - 4 x ^ 2 = 0
Q .3 Solve dy dx + y = 0
Q .4 Solve dy dx + 7 y = 0
Q .5 Solve 3 dy dx + 2 y = sinx
PRACTICAL 2
PLOTTING OF FAMILY OF SOLUTIONS OF DIFFERENCTIAL
EQUATIONS FIRST SECOND AND THIRD ORDER
ⅇ- 2 C[1] + 1 ⅇ- 2 1 - ⅈ x + 1 + ⅈ x
2 2
x x π 1 + 2 ⅈ Erfi 1 - 2 ⅈ Erfi
2 10 2 2
10
Out[7]=
-2 -1 1 2
In[12]:= Plot[Evaluate[y[x] /. soll /. {C[1] → {3, 19}, C[2] → {2, 0}}], {x, - 10, 2}, PlotRange → All]
140 000
120 000
100 000
80 000
Out[12]=
60 000
40 000
20 000
-10 -8 -6 -4 -2 2
In[19]:= Q .4 Solve d ^ 3 y dx ^ 3 + 3 d ^ 2 y dx ^ 2 - 4 y = 0
sol = DSolve[y '''[x] + 3 y ''[x] - 4 y[x] ⩵ 0, y[x], x]
Out[19]= 0
3 d2 y 0.4 d3 Q Solve y
Set: Tag Plus in -4 y + + is Protected.
dx2 dx3
3 d2 y 0.4 d3 Q Solve y
Set: Tag Plus in -4 y + + is Protected.
dx2 dx3
Out[13]= 0
20
10
Out[39]=
-4 -2 2
-10
-20
-30
PRACTICAL 3
VARIATIONS OF PARAMETERS
In[30]:= x2 y ' - 2 xy ' + 2 y = x3 using method of variation of parameters
eqn = x2 * y ''[x] - 2 * x * y '[x];
a[x] = x2 ;
r[x] = x3 ;
sol = DSolve[eqn ⩵ 0, y[x], x];
sol1 = y[x] /. sol[[1]]
Print["The general solution of corresponding homogenous equation is y[x]=", sol1,
"where c1 and c2 are arbitrary constants"]
y1[x] = x;
y2[x] = x2 ;
w = Wronskian[{y1[x], y2[x]}, x];
u[x] = Integrate- y2[x] * r[x] (a[x] * w), x;
v[x] = Integratey1[x] * r[x] (a[x] * w), x;
sol2 = u[x] y1[x] + v[x] * y2[x];
Print["The particular integral of non homogenous equation is:", sol2]
Print["The general solution of non homogenous equation is y[x]=", sol1 + sol2]
Out[35]=
1 x3 C[1] + C[2]
3
The general solution of corresponding homogenous equation is y[x]=
1 3
x C[1] + C[2]where c1 and c2 are arbitrary constants
3
x3
The particular integral of non homogenous equation is:
2
x3 1 3
The general solution of non homogenous equation is y[x]= + x C[1] + C[2]
2 3
PRACTICAL 4
GROWTH DECAY MODEL
8 × 1084
6 × 1084
Out[79]= 4 × 1084
2 × 1084
42 44 46 48 50
7. × 10-15
6. × 10-15
5. × 10-15
4. × 10-15
Out[84]=
3. × 10-15
2. × 10-15
1. × 10-15
10 20 30 40 50
PRACTICAL 5
LAKE POLLUTION MODEL
a) Constant Flow
3
In[85]:= ClearAll[Cin, V, F, t, C]
Cin = 3
V = 58
F=8
de = c '[t] ⩵ (F / V) * Cin - c[t]
sol = DSolve[{de, c[0] ⩵ c0}, c[t], t]
Plot[Evaluate[c[t] /. sol /. c0 → Range[1, 20]], {t, 0, 30}]
Out[86]= 3
Out[87]= 58
Out[88]= 8
10
Out[91]=
6
5 10 15 20 25 30
In[92]:= ClearAll[Cin, V, F, t, C]
Cin = 1 + 6 * Sin[2 * Pi * t];
V = 28;
de1 = C '[t] ⩵ Cin * 10 - C[t] V
sol1 = DSolve[{de1, C[0] ⩵ C0}, C[t], t]
Plot[Evaluate[C[t] /. sol1 /. C0 → Range[1, 20]], {t, 0, 10}]
20
15
Out[97]= 10
2 4 6 8 10
ClearAll[Cin, V, F, t, C]
Cin = 10 + 5 * Cos[2 * Pi * t];
V = 28;
de2 = C '[t] ⩵ Cin * 10 - C[t] V
sol2 = DSolve[{de2, C[0] ⩵ C0}, C[t], t]
Plot[Evaluate[C[t] /. sol2 /. C0 → Range[1, 20]], {t, 0, 10}]
Out[98]= 10 + 5 Cos[2. pi.t]
14
12
10
2 4 6 8 10
PRACTICAL 6
DENSITY DEPENDENT GROWTH
6
In[105]:= Needs["PlotLegends`"]
b1 = 1
a2 = 0.5
c1 = 0.01
c2 = 0.005
k = 1000
equa1 = x '[t] ⩵ b1 x[t] 1 - x[t] k - c1 x[t] y[t]
equa2 = y '[t] ⩵ c2 x[t] y[t] - a2 y[t]
s = NDSolve[{equa1, equa2, x[0] ⩵ 200, y[0] ⩵ 80}, {x, y}, {t, 0, 20}]
Plot[Evaluate[{x[t], y[t]} /. s], {t, 0, 20}, PlotRange → All,
PlotStyle → {{Red, Thickness[0.02]}, {Blue, Thickness[0.03]}},
AxesLabel → {"t Years", "Population Density"},
PlotLegends → {"x[t] Pray", "y[t] Predators"}]
Out[106]= 1
Out[107]= 0.5
Out[108]= 0.01
Out[109]= 0.005
Out[110]= 1000
Population Density
200
150
x[t] Pray
Out[114]=
y[t] Predators
100
t Years
5 10 15 20
PRACTICAL 7
PREDITOR PREY MODEL
7
Out[117]= 0.5
Out[118]= 0.01
Out[119]= 0.005
Population Density
200
150
x[t] Pray
Out[123]=
y[t] Predators
100
50
t Years
5 10 15 20
b) Effect of DDT
8
In[124]:= Needs["PlotLegends`"]
b1 = 1
a2 = 0.5
c1 = 0.01
c2 = 0.005
p1 = 0.1
p2 = 0.1
equa1 = x '[t] ⩵ b1 x[t] - c1 x[t] y[t] - p1 x[t]
equa2 = y '[t] ⩵ c2 x[t] y[t] - a2 y[t] - p2 y[t]
s = NDSolve[{equa1, equa2, x[0] ⩵ 200, y[0] ⩵ 80}, {x, y}, {t, 0, 20}]
Plot[Evaluate[{x[t], y[t]} /. s], {t, 0, 20}, PlotRange → All,
PlotStyle → {{Red, Thickness[0.02]}, {Blue, Thickness[0.03]}},
AxesLabel → {"t Years", "Population Density"},
PlotLegends → {"x[t] Pray", "y[t] Predators"}]
Out[125]= 1
Out[126]= 0.5
Out[127]= 0.01
Out[128]= 0.005
Out[129]= 0.1
Out[130]= 0.1
Population Density
200
150
x[t] Pray
Out[134]=
y[t] Predators
100
t Years
5 10 15 20
In[135]:= Needs["PlotLegends`"]
b1 = 1
b2 = 1
a3 = 0.5
c1 = 0.01
c2 = 0.005
d1 = 0.002
d2 = 0.003
equa1 = x '[t] ⩵ b1 x[t] - c1 x[t] z[t]
equa2 = y '[t] ⩵ b2 y[t] - c2 y[t] z[t]
equa3 = z '[t] ⩵ d1 x[t] z[t] + d2 y[t] z[t] - a3 z[t]
s = NDSolve[{equa1, equa2, equa3, x[0] ⩵ 200, y[0] ⩵ 80, z[0] ⩵ 50}, {x, y, z}, {t, 0, 20}]
Plot[Evaluate[{x[t], y[t], z[t]} /. s], {t, 0, 20}, PlotRange → All,
PlotStyle → {{Red, Thickness[0.02]}, {Blue, Thickness[0.03]}, {Green, Thickness[0.04]}},
AxesLabel → {"t Years", "Population Density"},
PlotLegends → {"x[t] Pray", "y[t] Predators", "z[t] Predators"}]
Out[136]= 1
Out[137]= 1
Out[138]= 0.5
Out[139]= 0.01
Out[140]= 0.005
Out[141]= 0.002
Out[142]= 0.003
Out[145]= z′ [t] ⩵ - 0.5 z[t] + 0.002 x[t] z[t] + 0.003 y[t] z[t]
Population Density
350
300
250
x[t] Pray
200
Out[147]= y[t] Predators
150
z[t] Predators
100
50
t Years
5 10 15 20