You are on page 1of 8

Practical -2

Plotting of second order solution family of differ-


ential equation.
Que 1 ; Solve the second order differential equation d^2y/dx^2 + 7dy/dx +10y = 0.
In[102]:=

DSolvey ''[x] + 7 y '[x] + 10 y[x] ⩵ 0, y[x], x


Out[102]=

y[x] → ⅇ-5 x 1 + ⅇ-2 x 2

Que 2 ; Solve the second order differential equation d^2y/dx^2 +y = 0.


In[103]:=

DSolve[y ''[x] + y[x] ⩵ 0, y[x], x]


Out[103]=

y[x] → 1 Cos[x] + 2 Sin[x]

Que 3 ; Solve the second order differential equation d^2y/dx^2 + dy/dx -6y = 0.
In[104]:=

DSolvey ''[x] + y '[x] - 6 y[x] ⩵ 0, y[x], x


Out[104]=

y[x] → ⅇ-3 x 1 + ⅇ2 x 2

Que 4 ; Solve the second order differential equation 4(d^2y)/dx^2 +12 dy/dx +9y = 0.
In[105]:=

DSolve4 y ''[x] + 12 y '[x] + 9 y[x] ⩵ 0, y[x], x


Out[105]=
-3 x2 -3 x2
y[x] → ⅇ 1 + ⅇ x 2

Que 5 ; Solve the second order differential equation (d^2y)/dx^2 -6 dy/dx +13y = 0
In[106]:=

DSolvey ''[x] - 6 y '[x] + 13 y[x] ⩵ 0, y[x], x


Out[106]=

y[x] → ⅇ3 x 2 Cos2 x + ⅇ3 x 1 Sin2 x

Que 6 ; Solve the second order differential equation (d^2y)/dx^2 -2 dy/dx +y = 0


2

In[107]:=

DSolvey ''[x] - 2 y '[x] + y[x] ⩵ 0, y[x], x


Out[107]=

y[x] → ⅇx 1 + ⅇx x 2

Plotting of solutions of second order


differential equations.
Que 1 ; Solve the second order differential equation (d^2y)/dx^2 +y = 0 and plot its
three solutions.
In[108]:=

sol = DSolve[y ''[x] + y[x] ⩵ 0, y[x], x]


sol1 = Evaluate[y[x] /. sol〚1〛 /. {C[1] → 1, C[2] → 2}]
sol2 = y[x] /. sol〚1〛 /. {C[1] → 1 / 2, C[2] → 5}
sol3 = y[x] /. sol〚1〛 /. {C[1] → - 1, C[2] → - 4}
Plot[{sol1, sol2, sol3}, {x, - 20, 20}]

Out[108]=

y[x] → 1 Cos[x] + 2 Sin[x]

Out[109]=

Cos[x] + 2 Sin[x]
Out[110]=
Cos[x]
+ 5 Sin[x]
2
Out[111]=

- Cos[x] - 4 Sin[x]

Out[112]=

-20 -10 10 20

-2

-4
3

Que 2 ; Solve the second order differential equation (d^2y)/dx^2 + dy/dx-6y = 0 and
plot its three solutions.
In[113]:=

sol = DSolvey ''[x] + y '[x] - 6 y[x] ⩵ 0, y[x], x


sol1 = Evaluate[y[x] /. sol〚1〛 /. {C[1] → 0, C[2] → 2.5}]
sol2 = y[x] /. sol〚1〛 /. {C[1] → 1, C[2] → 5}
sol3 = y[x] /. sol〚1〛 /. {C[1] → - 1 / 2, C[2] → 5}
Plot[{sol1, sol2, sol3}, {x, - 2, 2}]

Out[113]=

y[x] → ⅇ-3 x 1 + ⅇ2 x 2

Out[114]=

2.5 ⅇ2 x
Out[115]=

ⅇ-3 x + 5 ⅇ2 x

Out[116]=
1
- ⅇ-3 x + 5 ⅇ2 x
2
Out[117]=
200

150

100

50

-2 -1 1 2

-50

-100

Que 3 ; Solve the second order differential equation 4 (d^2y)/dx^2 + 12dy/dx+9y = 0


and plot its four solutions.
4

In[118]:=

sol = DSolve4 y ''[x] + 12 y '[x] + 9 y[x] ⩵ 0, y[x], x


sol1 = Evaluate[y[x] /. sol〚1〛 /. {C[1] → - 1, C[2] → 4}]
sol2 = y[x] /. sol〚1〛 /. {C[1] → 3, C[2] → 6}
sol3 = y[x] /. sol〚1〛 /. {C[1] → - 10, C[2] → 7}
sol4 = y[x] /. sol〚1〛 /. {C[1] → - 1.5, C[2] → - 5}
Plot[{sol1, sol2, sol3, sol4}, {x, - 2, 2}]

Out[118]=

-3 x2 -3 x2
y[x] → ⅇ 1 + ⅇ x 2

Out[119]=
-3 x2 -3 x2
-ⅇ +4ⅇ x
Out[120]=

3 ⅇ-3 x2 + 6 ⅇ-3 x2 x


Out[121]=
-3 x2 -3 x2
- 10 ⅇ +7ⅇ x
Out[122]=

-3 x2 -3 x2
- 1.5 ⅇ -5ⅇ x
Out[123]=

50

-2 -1 1 2

-50

-100

Que 4 ; Solve the second order differential equation 4(d^2y)/dx^2 -6 dy/dx+13y = 0


and plot its three solutions
5

In[39]:=

sol = DSolve4 y ''[x] - 6 y '[x] + 13 y[x] ⩵ 0, y[x], x


sol1 = Evaluate[y[x] /. sol〚1〛 /. {C[1] → - 1, C[2] → 4}]
sol2 = y[x] /. sol〚1〛 /. {C[1] → 3, C[2] → 6}
sol3 = y[x] /. sol〚1〛 /. {C[1] → - 10, C[2] → 7}
Plot[{sol1, sol2, sol3}, {x, - 5, 5}]

Out[39]=

3 x4
43 x 3 x4
43 x
y[x] → ⅇ 2 Cos +ⅇ 1 Sin 
4 4
Out[40]=

43 x 43 x
4 ⅇ3 x4 Cos -ⅇ
3 x4
Sin 
4 4
Out[41]=

43 x 43 x
6 ⅇ3 x4 Cos +3ⅇ
3 x4
Sin 
4 4
Out[42]=

43 x 43 x
7 ⅇ3 x4 Cos  - 10 ⅇ
3 x4
Sin 
4 4
Out[43]=

40

20

-4 -2 2 4

-20

-40

Que 5 ; Solve the second order differential equation (d^2y)/dx^2 -2 dy/dx+y = 0 and
plot its any five solutions.
6

In[44]:=

sol = DSolvey ''[x] - 2 y '[x] + y[x] ⩵ 0, y[x], x


sol1 = Evaluate[y[x] /. sol〚1〛 /. {C[1] → 0.5, C[2] → 3}]
sol2 = y[x] /. sol〚1〛 /. {C[1] → - 3, C[2] → - 2}
sol3 = y[x] /. sol〚1〛 /. {C[1] → - 1, C[2] → 7}
sol4 = y[x] /. sol〚1〛 /. {C[1] → - 6, C[2] → 1}
sol5 = y[x] /. sol〚1〛 /. {C[1] → 1 / 5, C[2] → 2 / 3}
Plot[{sol1, sol2, sol3, sol4, sol5}, {x, - 5, 5}]

Out[44]=

y[x] → ⅇx 1 + ⅇx x 2

Out[45]=

0.5 ⅇx + 3 ⅇx x
Out[46]=

- 3 ⅇx - 2 ⅇx x

Out[47]=

- ⅇx + 7 ⅇx x

Out[48]=

- 6 ⅇx + ⅇx x

Out[49]=

ⅇx 2 ⅇx x
+
5 3
Out[50]=

100

50

-4 -2 2 4

-50

Que 6 ; Solve the second order differential equation x^2(d^2y)/dx^2 -x dy/dx+y =


2log(x) and plot its any five solutions.
7

In[84]:=

sol = DSolvex ^ 2 y ''[x] - xy '[x] + y[x] ⩵ 2 log[x], y[x], x


sol1 = Evaluate[y[x] /. sol〚1〛 /. {C[1] → 0.5, C[2] → 3}]
sol2 = y[x] /. sol〚1〛 /. {C[1] → - 3, C[2] → - 2}
sol3 = y[x] /. sol〚1〛 /. {C[1] → - 1, C[2] → 7}
sol4 = y[x] /. sol〚1〛 /. {C[1] → - 6, C[2] → 1}
sol5 = y[x] /. sol〚1〛 /. {C[1] → 1 / 5, C[2] → 2 / 3}
Plot[{sol1, sol2, sol3, sol4, sol5}, {x, - 15, 15}]

Out[84]=
1 1
y[x] → x 1 Cos 3 Log[x] + x 2 Sin 3 Log[x] +
2 2
2 Sin 2 3 Log[K[1]] 2 log[K[1]] + xy′ [K[1]]
1
1 x
x Cos 3 Log[x]  - ⅆ K[1] +
2 1
3 K[1]32

Cos 2 3 Log[K[2]] 2 log[K[2]] + xy′ [K[2]]


1
1 x2
x Sin 3 Log[x]  ⅆ K[2]
2 1
3 K[2]32
Out[85]=
1 1
0.5 x Cos 3 Log[x] + 3 x Sin 3 Log[x] +
2 2
2 Sin 2 3 Log[K[1]] 2 log[K[1]] + xy′ [K[1]]
1
1 x
x Cos 3 Log[x]  - ⅆ K[1] +
2 1
3 K[1]32

Cos 2 3 Log[K[2]] 2 log[K[2]] + xy′ [K[2]]


1
1 x2
x Sin 3 Log[x]  ⅆ K[2]
2 1
3 K[2]32
Out[86]=
1 1
-3 x Cos 3 Log[x] - 2 x Sin 3 Log[x] +
2 2
2 Sin 2 3 Log[K[1]] 2 log[K[1]] + xy′ [K[1]]
1
1 x
x Cos 3 Log[x]  - ⅆ K[1] +
2 1
3 K[1]32

Cos 2 3 Log[K[2]] 2 log[K[2]] + xy′ [K[2]]


1
1 x2
x Sin 3 Log[x]  ⅆ K[2]
2 1
3 K[2]32
8

Out[87]=
1 1
- x Cos 3 Log[x] + 7 x Sin 3 Log[x] +
2 2
2 Sin 2 3 Log[K[1]] 2 log[K[1]] + xy′ [K[1]]
1
1 x
x Cos 3 Log[x]  - ⅆ K[1] +
2 1
3 K[1]32

Cos 2 3 Log[K[2]] 2 log[K[2]] + xy′ [K[2]]


1
1 x2
x Sin 3 Log[x]  ⅆ K[2]
2 1
3 K[2]32
Out[88]=
1 1
-6 x Cos 3 Log[x] + x Sin 3 Log[x] +
2 2
2 Sin 2 3 Log[K[1]] 2 log[K[1]] + xy′ [K[1]]
1
1 x
x Cos 3 Log[x]  - ⅆ K[1] +
2 1
3 K[1]32

Cos 2 3 Log[K[2]] 2 log[K[2]] + xy′ [K[2]]


1
1 x2
x Sin 3 Log[x]  ⅆ K[2]
2 1
3 K[2]32
Out[89]=
1 1 2 1
x Cos 3 Log[x] + x Sin 3 Log[x] +
5 2 3 2
2 Sin 2 3 Log[K[1]] 2 log[K[1]] + xy′ [K[1]]
1
1 x
x Cos 3 Log[x]  - ⅆ K[1] +
2 1
3 K[1]32

Cos 2 3 Log[K[2]] 2 log[K[2]] + xy′ [K[2]]


1
1 x2
x Sin 3 Log[x]  ⅆ K[2]
2 1
3 K[2]32
Out[90]=

1.0

0.5

-15 -10 -5 5 10 15

-0.5

-1.0

You might also like