You are on page 1of 30

Practical 1: Solving differential equations using mathematica

DSolve@y '@xD + y@xD Š a * Sin@xD, y@xD, xD

::y@xD ® ã-x C@1D + a H- Cos@xD + Sin@xDL>>


1
2

DSolve@Hy '@xDL ^ 2 Š Sin@xD, y@xD, xD

::y@xD ® C@1D - 2 EllipticEB K - xO, 2F>, :y@xD ® C@1D + 2 EllipticEB K


1 p 1 p
- xO, 2F>>
2 2 2 2

DSolve@y '@xD Š Sin@xD, y@xD, xD


88y@xD ® C@1D - Cos@xD<<

DSolve@y '@xD Š HSin@xDL ^ H1 • 2L, y@xD, xD

::y@xD ® C@1D - 2 EllipticEB K


1 p
- xO, 2F>>
2 2

DSolve@y '@xD Š Hx + y@xDL • Hx - y@xDL, y@xD, xD

F+ F Š C@1D - Log@xD, y@xDF


y@xD 1 y@xD2
SolveB- ArcTanB LogB1 +
x 2 x2

Clear@y, xD

DSolve@8y '@xD + y@xD Š a * Sin@xD, y@0D Š 0<, y@xD, xD

::y@xD ® - a ã-x H- 1 + ãx Cos@xD - ãx Sin@xDL>>


1
2

Clear@y, xD

DSolve@y ''@xD + y@xD Š Exp@- xD, y@xD, xD

::y@xD ® C@1D Cos@xD + C@2D Sin@xD + ã-x ICos@xD2 + Sin@xD2 M>>


1
2

Clear@y, xD

DSolve@Hx + y@xDL * y '@xD Š x - y@xD, y@xD, xD

::y@xD ® - x - ã2 C@1D + 2 x2 >, :y@xD ® - x + ã2 C@1D + 2 x2 >>

Clear@y, xD

DSolve@y '@xD Š Hx + y@xD + 1L ^ H1 • 2L, y@xD, xD


Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. ‡

::y@xD ® - x + 2 ProductLogB- ã-1- 2 - F + ProductLogB- ã-1- 2 - F >>


x C@1D x C@1D 2
2 2

Clear@y, xD
2 jyoti.nb

DSolve@Hx ^ 2L * y '@xD + 2 * x * y@xD Š 5 * Hy@xDL ^ 4, y@xD, xD


H- 7L1•3 x1•3 H- 1L2•3 71•3 x1•3
::y@xD ® - >, :y@xD ® >, :y@xD ® >>
71•3 x1•3

I15 + 7 x7 C@1DM I15 + 7 x7 C@1DM I15 + 7 x7 C@1DM


1•3 1•3 1•3

Clear@y, xD

DSolve@82 * y@xD * y '@xD Š x • HHx ^ 2 - 16L ^ H1 • 2LL, y@5D Š 2<, y@xD, xD

DSolve::bvnul : For some branches of the general solution, the given boundary conditions lead to an empty solution. ‡

::y@xD ® 1+ - 16 + x2 >>

Clear@y, xD

DSolve@82 * Sqrt@xD * y '@xD Š HCos@y@xDDL ^ 2, y@4D Š Pi • 4<, y@xD, xD


Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. ‡

::y@xD ® - ArcTanA1 - x E>>

Clear@y, xD

ClearAll
ClearAll

Clear@y, xD

DSolve@8y ''@xD - 2 * y '@xD + 2 * y@xD == 2 x, y@0D Š 4, y '@0D Š 8<, y@xD, xD


88y@xD ® 1 + x + 3 ãx Cos@xD + 4 ãx Sin@xD<<

Clear@y, xD

DSolve@
8y '''@xD - 6 * y ''@xD + 11 * y '@xD - 6 * y@xD Š 0, y@0D Š 0, y '@0D Š 0, y ''@0D Š 3<, y@xD, xD

::y@xD ® ãx H- 1 + ãx L2 >>
3
2

DSolve@y '@xD Š Csc@2 * x + y@xDD, y@xD, xD


F
F
y@xD
2+TanBx+
2
ArcTanhB
3 y@xD
SolveB- - Š C@1D, y@xDF
3 2

Clear@y, xD

DSolve@y '@xD Š Csc@2 * x + y@xDD, y@xD, xD


F
F
y@xD
2+TanBx+
2
ArcTanhB
3 y@xD
SolveB- - Š C@1D, y@xDF
3 2
jyoti.nb 3

Practical 2: Plotting second order solution families


eqn = y ''@xD + y@xD Š 0
y@xD + y¢¢ @xD Š 0

sol = DSolve@eqn, y@xD, xD


88y@xD ® C@1D Cos@xD + C@2D Sin@xD<<

Plot@
Evaluate@y@xD •. sol •. 8C@1D ® Range@- 15, 15D, C@2D ® Range@- 15, 15D<D, 8x, - 5, 5<D
20

10

-4 -2 2 4

-10

-20

sol1 = DSolve@y ''@xD + 2 * y@xD + 1 Š 0, y@xD, xD

::y@xD ® -
1
+ C@1D CosB 2 xF + C@2D SinB 2 xF>>
2

Plot@
Evaluate@y@xD •. sol1 •. 8C@1D ® Range@- 10, 10D, C@2D ® Range@- 10, 10D<D, 8x, - 5, 5<D

10

-4 -2 2 4

-5

-10

-15

sol2 = DSolve@x ^ 2 * y ''@xD + x * y '@xD + 9 * y@xD Š 0, y@xD, xD


88y@xD ® C@1D Cos@3 Log@xDD + C@2D Sin@3 Log@xDD<<
4 jyoti.nb

Plot@Evaluate@y@xD •. sol2 •. 8C@1D ® Range@- 5, 5D, C@2D ® Range@- 5, 5D<D, 8x, - 7, 7<D

-6 -4 -2 2 4 6

-2

-4

-6

sol3 = DSolve@Hx ^ 2L * y ''@xD + 2 * x * y '@xD - 12 * y@xD Š 0, y@xD, xD

::y@xD ® x3 C@1D + >>


C@2D
x4

Plot@
Evaluate@y@xD •. sol3 •. 8C@1D ® Range@- 10, 10D, C@2D ® Range@- 10, 10D<D, 8x, - 10, 10<D

4000

2000

-10 -5 5 10

-2000

-4000
jyoti.nb 5

Manipulate@Plot@Hx ^ 3L * C@1D + C@2D • Hx ^ 4L, 8x, - 6, 6<D, 8C@1D, 1, 4<, 8C@2D, 0, 10<D

sol4 = DSolve@Hx ^ 2L * y ''@xD + 2 * x * y '@xD - 6 * y@xD Š 0, y@xD, xD

::y@xD ® x2 C@1D + >>


C@2D
x3

Plot@
Evaluate@y@xD •. sol4 •. 8C@1D ® Range@- 10, 10D, C@2D ® Range@- 10, 10D<D, 8x, - 10, 10<D

500

-10 -5 5 10

-500
6 jyoti.nb

, 8x, - 10, 10<F, 8C@1D, 1, 4<, 8C@2D, 0, 10<F


C@2D
ManipulateBPlotBx2 C@1D +
x3

sol5 = DSolve@y ''@xD - 10 * y '@xD + 25 * y@xD Š 0, y@xD, xD


99y@xD ® ã5 x C@1D + ã5 x x C@2D==

Plot@Evaluate@y@xD •. sol5 •. 8C@1D ® Range@- 3, 3D, C@2D ® Range@- 3, 3D<D, 8x, - 3, 3<D

150

100

50

-3 -2 -1 1 2 3

-50

-100

-150
jyoti.nb 7

ManipulateAPlotAã5 x C@1D + ã5 x x C@2D, 8x, - 6, 6<E, 8C@1D, 1, 4<, 8C@2D, 0, 10<E

Practical 3: Plotting third order solution families


sol6 = DSolve@y '''@xD + 3 * y ''@xD + 4 * y '@xD + 12 y@xD Š 0, y@xD, xD
99y@xD ® ã-3 x C@3D + C@1D Cos@2 xD + C@2D Sin@2 xD==
8 jyoti.nb

Plot@Evaluate@y@xD •. sol6 •.
8C@1D ® Range@- 5, 5D, C@2D ® Range@- 5, 5D, C@3D ® Range@- 5, 5D<D, 8x, - 5, 5<D
300

200

100

-4 -2 2 4

-100

-200

-300

sol7 = DSolve@9 * y '''@xD + 12 * y ''@xD + 4 * y '@xD Š 0, y@xD, xD

::y@xD ® - ã-2 x•3 H2 C@1D + H3 + 2 xL C@2DL + C@3D>>


3
4

Plot@Evaluate@y@xD •. sol7 •.
8C@1D ® Range@- 5, 5D, C@2D ® Range@- 5, 5D, C@3D ® Range@- 5, 5D<D, 8x, - 5, 5<D
30

20

10

-4 -2 2 4

-10

-20

-30

sol8 = DSolve@y '''@xD + 3 * y ''@xD + 4 * y '@xD - 8 * y@xD Š 0, y@xD, xD


99y@xD ® ãx C@3D + ã-2 x C@2D Cos@2 xD + ã-2 x C@1D Sin@2 xD==
jyoti.nb 9

Plot@Evaluate@y@xD •. sol8 •.
8C@1D ® Range@- 5, 5D, C@2D ® Range@- 5, 5D, C@3D ® Range@- 5, 5D<D, 8x, - 5, 5<D

400

200

-4 -2 2 4

-200

-400

sol9 = DSolve@3 * y '''@xD - 2 * y ''@xD + 12 y '@xD - 8 * y@xD Š 0, y@xD, xD


99y@xD ® ã2 x•3 C@3D + C@1D Cos@2 xD + C@2D Sin@2 xD==

Plot@Evaluate@y@xD •. sol9 •.
8C@1D ® Range@- 5, 5D, C@2D ® Range@- 5, 5D, C@3D ® Range@- 5, 5D<D, 8x, - 5, 5<D
30

20

10

-4 -2 2 4

-10

-20

-30

sol10 = DSolve@Hx ^ 3L * y '''@xD + 6 * Hx ^ 2L * y ''@xD + 7 * x * y '@xD + y@xD Š 0, y@xD, xD

::y@xD ® >>
C@1D C@2D Log@xD C@3D Log@xD2
+ +
x x x
10 jyoti.nb

Plot@Evaluate@y@xD •. sol10 •.
8C@1D ® Range@- 5, 5D, C@2D ® Range@- 5, 5D, C@3D ® Range@- 5, 5D<D, 8x, - 5, 5<D

15

10

-4 -2 2 4

-5

-10

-15

, 8x, - 5, 5<F,
C@1D C@2D Log@xD C@3D Log@xD2
ManipulateBPlotB + +
x x x
8C@1D, - 5, 5<, 8C@2D, - 5, 5<, 8C@3D, - 5, 5<F
jyoti.nb 11

Practical 4: exponential growth and decay model


Question: Taking the 1990 world population value statistics, r=0.017 and x0=5.3billion,
apply exponential growth model to predict the population of the world in 100 years.

DSolve@8x '@tD Š r * x@tD, x@0D Š 5.3<, x@tD, tD


99x@tD ® 5.3 ãr t ==

Plot@5.3 Exp@0.017 tD, 8t, 0, 100<D

25

20

15

10

20 40 60 80 100

5.3 Exp@0.017 * 100D


29.0119

The expected population of the world in 100 years from 1990 is 29.0119 billion.

Question: When sugar is dissolved in water, the amount of sugar A, which remains undis-
solved after t minutes satisfies the differential equation dA/dt=-0.5A. Find an expression for
A in terms of t and decipt it graphically.
DSolve@A '@tD Š - 0.5 A@tD, A@tD, tD
99A@tD ® ã-0.5 t C@1D==
12 jyoti.nb

Plot @8Exp@- 0.5 tD, 2 * Exp@- 0.5 tD, 3 * Exp@- 0.5 tD<, 8t, 0, 100<D
0.0007

0.0006

0.0005

0.0004

0.0003

0.0002

0.0001

20 40 60 80 100

Practical 5:limited growth model


Logistic Model without Harvesting.
Question: Depict the logistic growth model graphically for different val-
ues of initial population. Take reproduction rate[r] as unity and the carry-
ing capacity of population[k] as 1000.
r=1
1

k = 1000
1000

de = D@x@tD, tD Š r * x@tD - Hr • kL * Hx@tDL ^ 2

x¢ @tD Š x@tD -
x@tD2
1000

sol = DSolve@8de, x@0D Š x0<, x@tD, tD


Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. ‡

::x@tD ® >>
1000 ãt x0
1000 - x0 + ãt x0
jyoti.nb 13

Plot@Evaluate@x@tD •. sol •. x0 ® Range@1, 20DD, 8t, 0, 10<D


1000

800

600

400

200

2 4 6 8 10

Plot@Evaluate@x@tD •. sol •. x0 ® Range@1500, 1600DD, 8t, 0, 10<D

1150

1100

1050

2 4 6 8 10

r=2
2

k = 1000
1000

de = D@x@tD, tD Š r * x@tD - Hr • kL * Hx@tDL ^ 2

x¢ @tD Š 2 x@tD -
x@tD2
500

sol = DSolve@8de, x@0D Š x0<, x@tD, tD


Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. ‡

::x@tD ® >>
1000 ã2 t x0
1000 - x0 + ã2 t x0
14 jyoti.nb

Plot@Evaluate@x@tD •. sol •. x0 ® Range@1, 20DD, 8t, 0, 10<D


1000

800

600

400

200

2 4 6 8 10

Question: Write down the differential equation describing limited growth


of population with a constant harvesting rate[h]=9/10, carrying capacity
of population[k]=10 and reproduction rate[r]=1. Find an expresson for
population at any time t in terms of t and depict the solution curve graphi-
cally for different initial values of population.
R=1
1

K = 10
10

H = 9 • 10
9
10

DE = D@x@tD, tD Š - HR • KL * HHx@tDL ^ 2 - K * x@tD + K * H • RL

x¢ @tD Š I- 9 + 10 x@tD - x@tD2 M


1
10

SOL = DSolve@8DE, x@0D Š x0<, x@tD, tD


Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. ‡

::x@tD ® >>
9 - 9 ã4 t•5 - x0 + 9 ã4 t•5 x0
9 - ã4 t•5 - x0 + ã4 t•5 x0
jyoti.nb 15

Plot@Evaluate@x@tD •. SOL •. x0 ® Range@1, 25DD, 8t, 0, 50<D


9.00015

9.00010

9.00005

9.00000

8.99995

10 20 30 40 50

R=2
2

K = 10
10

H = 9 • 10
9
10

DE = D@x@tD, tD Š - HR • KL * HHx@tDL ^ 2 - K * x@tD + K * H • RL

x¢ @tD Š
1 9
- + 10 x@tD - x@tD2
5 2

SOL = DSolve@8DE, x@0D Š x0<, x@tD, tD


Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. ‡

82 t 82 t 82 t

::x@tD ® >>
9-9ã 5 - 10 x0 + 82 x0 + 10 ã 5 x0 + 82 ã 5 x0
82 t 82 t 82 t
10 + 82 - 10 ã 5 + 82 ã 5 - 2 x0 + 2 ã 5 x0
16 jyoti.nb

Plot@Evaluate@x@tD •. SOL •. x0 ® Range@1, 25DD, 8t, 0, 50<D

9.52769

9.52769

9.52769

9.52769

9.52769

10 20 30 40 50

Practical 6: drug/cold pill assimilation


Case of a Single Pill
k1 = 1.386
1.386

k2 = 0.1386
0.1386

de1 = x '@tD Š - k1 * x@tD


x¢ @tD Š - 1.386 x@tD

de2 = y '@tD == k1 * x@tD - k2 * y@tD


y¢ @tD Š 1.386 x@tD - 0.1386 y@tD

sol = NDSolve@8de1, de2, x@0D Š 1, y@0D Š 0<, 8x@tD, y@tD<, 8t, 0, 20<D
88x@tD ® InterpolatingFunction@880., 20.<<, <>D@tD,
y@tD ® InterpolatingFunction@880., 20.<<, <>D@tD<<
jyoti.nb 17

Plot@Evaluate@8x@tD, y@tD< •. solD, 8t, 0, 20<, PlotRange ® All,


PlotStyle ® 8Blue, Red<, PlotLegends ® 8"Gastro-Intestinal Tract", "Bloodstream"<D
1.0

0.8

0.6
Gastro-Intestinal Tract

0.4
Bloodstream

0.2

5 10 15 20

Description:
The initial concentration of the pill in the gastro intestinal tract is same as the
initial concentration of the pill, that is, 1. And therefore, the first graph starts at 1
on the y-axis. The concentration of the pill in the gastro-intestinal tract decreases
as the drug diffuses into the bloodstream. Thus, the graph showing concentra-
tion in the gastro-intestinal tract decreases, and the corresponding graph of the
bloodstream increases. Finally, after a certain time, the concentration of drug in
the bloodstream also starts decreasing.
Case of a Course of Pills:
K1 = 1.386
1.386

K2 = 0.1386
0.1386

DE1 = u '@tD Š 1 - K1 * u@tD


u¢ @tD Š 1 - 1.386 u@tD

DE2 = v '@tD Š K1 * u@tD - K2 * v@tD


v¢ @tD Š 1.386 u@tD - 0.1386 v@tD

SOL = NDSolve@8DE1, DE2, u@0D Š 0, v@0D Š 0<, 8u@tD, v@tD<, 8t, 0, 20<D
88u@tD ® InterpolatingFunction@880., 20.<<, <>D@tD,
v@tD ® InterpolatingFunction@880., 20.<<, <>D@tD<<
18 jyoti.nb

Plot@Evaluate@8u@tD, v@tD< •. SOLD, 8t, 0, 20<, PlotRange ® All,


PlotStyle ® 8Blue, Red<, PlotLegends ® 8"Gastro-Intestinal Tract", "Bloodstream"<D

4
Gastro-Intestinal Tract
3 Bloodstream

5 10 15 20

Description:
Both the graphs start from zero, since the initial concentration of the drug in both,
the gastro-intestinal tract and the bloodstream is zero. There is a constant inges-
tion rate=1. As the pill is taken at certain constant intervals of time, gradually the
concentration of the drug in both the chambers reaches a certain fixed value. Till
the time the pill continues to be taken at such constant intervals, the body main-
tains a constant concentration of the drugs.
jyoti.nb 19

Practical 7: Lake Pollution Model


a) With constant rate flow
cin = 3;
v = 28;
F = 48;
de = D@C@tD, tD Š HF • vL * Hcin - C@tDL
sol = DSolve@8de, C@0D Š CO<, C@tD, tD
Plot @Evaluate@C@tD •. sol •. CO ® Range@0, 20DD, 8t, 0, 10<D

C¢ @tD Š H3 - C@tDL
12
7
99C@tD ® ã-12 t•7 I- 3 + CO + 3 ã12 t•7 M==

3.4

3.3

3.2

3.1

3.0

2.9

2.8

2 4 6 8 10
20 jyoti.nb

cin = 4;
v = 25;
F = 60;
de = D@C@tD, tD Š HF • vL * Hcin - C@tDL
sol = DSolve@8de, C@0D Š CO<, C@tD, tD
Plot @Evaluate@C@tD •. sol •. CO ® Range@- 20, 30DD, 8t, 0, 10<D

C¢ @tD Š H4 - C@tDL
12
5
99C@tD ® ã-12 t•5 I- 4 + CO + 4 ã12 t•5 M==

4.005

4.000

3.995

2 4 6 8 10
jyoti.nb 21

b) With seasonal flow rate

V = 28;
de1 = D@C@tD, tD Š HH1 + 6 Sin@2 * Pi * tDL * H10 - C@tDLL • V
sol1 = DSolve @8de1, C@0D Š co<, C@tD, tD
Plot @Evaluate @C@tD •. sol1 •. co ® Range @2, 20DD, 8t, 0, 10<D

C¢ @tD Š H10 - C@tDL H1 + 6 Sin@2 p tDL


1
28

::C@tD ® ã >>
3 t 3 t 3 Cos@2 p tD 3 Cos@2 p tD
- - +
28 p 28 10 ã 28 p 28 - 10 ã 28 p + co ã 28 p

20

15

10

2 4 6 8 10
22 jyoti.nb

V = 28;
de1 = D@C@tD, tD Š HH1 + Cos@2 * Pi * tDL * H10 - C@tDLL • V
sol1 = DSolve @8de1, C@0D Š co<, C@tD, tD
Plot @Evaluate @C@tD •. sol1 •. co ® Range @2, 20DD, 8t, 0, 10<D

C¢ @tD Š H10 - C@tDL H1 + Cos@2 p tDL


1
28

::C@tD ® ã >>
t Sin@2 p tD t Sin@2 p tD
- - +
28 56 p - 10 + co + 10 ã 28 56 p

20

15

10

2 4 6 8 10

V = 28;
de1 = D@C@tD, tD Š HH1 + 4 Tan@2 * Pi * tDL * H10 - C@tDLL • V
sol1 = DSolve @8de1, C@0D Š co<, C@tD, tD
Plot @Evaluate @C@tD •. sol1 •. co ® Range @2, 20DD, 8t, 0, 10<D

C¢ @tD Š H10 - C@tDL H1 + 4 Tan@2 p tDL


1
28

::C@tD ® ã-t•28 10 ãt•28 - 10 Cos@2 p tD 14 p + co Cos@2 p tD 14 p >>


1 1

20

15

10

2 4 6 8 10

PRACTICAL 8
jyoti.nb 23

PRACTICAL 8
PREDATOR PREY MODEL
a) LOTKA- VOLTERRA MODEL
b1 = 1;

a2 = 0.5;

c1 = 0.01;

c2 = 0.005;

de1 = x '@tD == b1 * x@tD - c1 * x@tD * y@tD


x¢ @tD Š x@tD - 0.01 x@tD y@tD

de2 = y '@tD Š c2 * x@tD * y@tD - a2 * y@tD


y¢ @tD Š - 0.5 y@tD + 0.005 x@tD y@tD

sol = NDSolve@8de1, de2, x@0D Š 200, y@0D Š 80<, 8x@tD, y@tD<, 8t, 0, 50<D
88x@tD ® InterpolatingFunction@880., 50.<<, <>D@tD,
y@tD ® InterpolatingFunction@880., 50.<<, <>D@tD<<

Plot@Evaluate@8x@tD, y@tD< •. solD, 8t, 0, 50<,


PlotRange ® All, PlotLegends ® 8"Prey", "Predator"<D

200

150

Prey
Predator
100

50

10 20 30 40 50

b) EFFECT OF DDT ON MODEL


b1 = 1;

a2 = 0.5;

c1 = 0.01
0.01
24 jyoti.nb

c2 = 0.005
0.005

p1 = 0.1;

p2 = 0.1;

de1 = x '@tD Š b1 * x@tD - c1 * x@tD * y@tD - p1 * x@tD


x¢ @tD Š 0.9 x@tD - 0.01 x@tD y@tD

de2 = y '@tD Š c2 * x@tD * y@tD - a2 * y@tD - p2 * y@tD


y¢ @tD Š - 0.6 y@tD + 0.005 x@tD y@tD

sol = NDSolve@8de1, de2, x@0D Š 200, y@0D Š 80<, 8x@tD, y@tD<, 8t, 0, 20<D
88x@tD ® InterpolatingFunction@880., 20.<<, <>D@tD,
y@tD ® InterpolatingFunction@880., 20.<<, <>D@tD<<

Plot@Evaluate@8x@tD, y@tD< •. solD, 8t, 0, 20<,


PlotRange ® All, PlotLegends ® 8"Prey", "Predator"<D

200

180

160

140
Prey
120 Predator
100

80

60
5 10 15 20

c) DENSITY DEPENDENCE FOR PREY POLPULATION


Clear@x, yD

b1 = 1;

a2 = 0.5;

c1 = 0.01;

c2 = 0.005;

k = 1000;

de1 = x '@tD Š b1 * x@tD * H1 - Hx@tD • kLL - c1 * x@tD * y@tD

x¢ @tD Š 1 -
x@tD
x@tD - 0.01 x@tD y@tD
1000
jyoti.nb 25

de2 = y '@tD Š c2 * x@tD * y@tD - a2 * y@tD


y¢ @tD Š - 0.5 y@tD + 0.005 x@tD y@tD

sol = NDSolve@8de1, de2, x@0D Š 120, y@0D Š 80<, 8x@tD, y@tD<, 8t, 0, 100<D
88x@tD ® InterpolatingFunction@880., 100.<<, <>D@tD,
y@tD ® InterpolatingFunction@880., 100.<<, <>D@tD<<

Plot@Evaluate@8x@tD, y@tD< •. solD, 8t, 0, 100<,


PlotRange ® All, PlotLegends ® 8"Prey", "Predator"<D

120

110

Prey
100
Predator

90

20 40 60 80 100

d) 2 PREY AND 1 PREDATOR


b1 = 1;

b2 = 0.5;

b3 = 0.5;

c1 = 0.01;

c2 = 0.01;

c3 = 0.01;

c4 = 0.01;

de1 = x '@tD Š b1 * x@tD - c1 * x@tD * z@tD


x¢ @tD Š x@tD - 0.01 x@tD z@tD

de2 = y '@tD Š b2 * y@tD - c2 * y@tD * z@tD


y¢ @tD Š 0.5 y@tD - 0.01 y@tD z@tD
26 jyoti.nb

de3 = z '@tD Š b3 * z@tD + c3 * x@tD * z@tD + c4 * y@tD * z@tD


z¢ @tD Š 0.5 z@tD + 0.01 x@tD z@tD + 0.01 y@tD z@tD

sol = NDSolve@8de1, de2, de3, x@0D Š 200, y@0D Š 180, z@0D Š 100<,
8x@tD, y@tD, z@tD<, 8t, 0, 10<D;

Plot@Evaluate@8x@tD, y@tD, z@tD< •. solD, 8t, 0, 1<,


PlotRange ® All, PlotLegends ® 8"prey1", "Prey2", "Predator"<D

800

600

prey1
400 Prey2
Predator

200

0.2 0.4 0.6 0.8 1.0

b1 = 1;

b2 = 0.5;

b3 = 0.5;

c1 = 0.01;

c2 = 0.01;

c3 = 0.01;

c4 = 0.01;

de1 = x '@tD Š b1 * x@tD - c1 * x@tD * z@tD


x¢ @tD Š x@tD - 0.01 x@tD z@tD

de2 = y '@tD Š b2 * y@tD - c2 * y@tD * z@tD


y¢ @tD Š 0.5 y@tD - 0.01 y@tD z@tD

de3 = z '@tD Š - b3 * z@tD + c3 * x@tD * z@tD + c4 * y@tD * z@tD


z¢ @tD Š - 0.5 z@tD + 0.01 x@tD z@tD + 0.01 y@tD z@tD
jyoti.nb 27

sol = NDSolve@8de1, de2, de3, x@0D Š 200, y@0D Š 180, z@0D Š 100<,
8x@tD, y@tD, z@tD<, 8t, 0, 10<D;

Plot@Evaluate@8x@tD, y@tD, z@tD< •. solD, 8t, 0, 5<,


PlotRange ® All, PlotLegends ® 8"prey1", "Prey2", "Predator"<D

400

300
prey1
Prey2
200
Predator

100

1 2 3 4 5

PRACTICAL 9
BATTLE MODEL

a)Aimed Firing from both sides


Q.During the battle of two Jima in the Pacific ocean (1945) daily records were kept of all the U.S
combat losses.The values of the attrition coefficients a1 and a2 have been estimated from the
data as a1=0.0544 and a2=0.0106 and the initial number of soldiers in the red and blue armies
respectively were r0=66454 and b0=18274.Obtain numerical solutions to the differential
equations(aimed firing from both the sides
) and plot the solution curves.
a1 = 0.0544
0.0544

a2 = 0.0106
0.0106

de1 = r '@tD Š - a1 * b@tD


r¢ @tD Š - 0.0544 b@tD
28 jyoti.nb

de2 = b '@tD Š - a2 * r@tD


b¢ @tD Š - 0.0106 r@tD

sol = NDSolve@8de1, de2, r@0D Š 66 454, b@0D Š 18 274<, 8r@tD, b@tD<, 8t, 0, 20<D;

Plot@Evaluate@8r@tD, b@tD< •. solD, 8t, 0, 20<, PlotRange ® All, PlotStyle ® 8Red, Blue<D

60 000

50 000

40 000

30 000

20 000

10 000

5 10 15 20

b)Jungle warfare (guerrilla warfare)(aimed fire from


one side and random fire from other side)
a1 = a2 = 0.01;

de1 = r '@tD Š - a1 * b@tD


de2 = b '@tD Š - a2 * r@tD * b@tD
sol = NDSolve@8de1, de2, r@0D Š 50, b@0D Š 100<, 8r@tD, b@tD<, 8t, 0, 10<D;
r¢ @tD Š - 0.01 b@tD

b¢ @tD Š - 0.01 b@tD r@tD

Plot@Evaluate@8r@tD, b@tD< •. solD, 8t, 0, 10<, PlotRange ® All, PlotStyle ® 8Red, Blue<D
100

80

60

40

20

2 4 6 8 10

c)Jungle warfare with constant reinforcements


jyoti.nb 29

c)Jungle warfare with constant reinforcements


a1 = a2 = 0.01;
de1 = r '@tD Š - a1 * b@tD + 10
de2 = b '@tD Š - a2 * r@tD * b@tD + 25
sol = NDSolve@8de1, de2, r@0D Š 50, b@0D Š 100<, 8r@tD, b@tD<, 8t, 0, 30<D;
r¢ @tD Š - 0.01` b@tD
b¢ @tD Š - 0.01` b@tD r@tD
Plot@Evaluate@8r@tD, b@tD< •. solD, 8t, 0, 30<, PlotRange ® All,
PlotStyle ® 8Red, Blue<, PlotLegends ® 8"red army", "blue army"<D
r¢ @tD Š 10 - 0.01 b@tD

b¢ @tD Š 25 - 0.01 b@tD r@tD

r¢ @tD Š - 0.01 b@tD

b¢ @tD Š - 0.01 b@tD r@tD

350

300

250

200
red army
150 blue army

100

50

5 10 15 20 25 30
30 jyoti.nb

d)Long range artillery (random fire both sides )


a1 = a2 = 0.01;
de1 = r '@tD Š - a1 * b@tD * r@tD
de2 = b '@tD Š - a2 * r@tD * b@tD
sol = NDSolve@8de1, de2, r@0D Š 66, b@0D Š 18<, 8r@tD, b@tD<, 8t, 0, 30<D;

Plot@Evaluate@8r@tD, b@tD< •. solD, 8t, 0, 30<, PlotRange ® All,


PlotStyle ® 8Red, Blue<, PlotLegends ® 8"red army", "blue army"<D
r¢ @tD Š - 0.01 b@tD r@tD

b¢ @tD Š - 0.01 b@tD r@tD

60

50

40
red army
30
blue army
20

10

5 10 15 20 25 30

You might also like