0% found this document useful (0 votes)
90 views11 pages

Practi-Cal-2: Plotting of Second Order Solution Fam - Ily of Differential Equation

Practical- 2 Plotting of second order solution family of differential equation.

Uploaded by

Rohit Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views11 pages

Practi-Cal-2: Plotting of Second Order Solution Fam - Ily of Differential Equation

Practical- 2 Plotting of second order solution family of differential equation.

Uploaded by

Rohit Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practi-

cal-2

Plotting of second order solution fam-


ily of differential equation.

Command: DSolve[eqn,y[x],x] solve a differential equa-


tion for y[x]

Question 1: Solve the second order differential equation


d^2y/dx^2+7dy/dx+10y=0.
In[17]:= DSolve [y '' [x] + 7 y '[x] + 10 y[x] ⩵ 0, y[x], x]
y[x] → ⅇ 1 + ⅇ  2 
-5 x -2 x
Out[17]=

Question 2: Solve the second order differential equation


d^2y/dx^2+y=0.

Solution:
In[18]:= DSolve [y '' [x] + y[x] ⩵ 0, y[x], x]
Out[18]= {{y[x] →  1 Cos [x] +  2 Sin [x]}}

Question 3: Solve second order differential equation (d^2


y)/dx^2+dy/dx-6y=0.
2

Solution:

In[19]:= DSolve [y '' [x] + y '[x] - 6 y[x] ⩵ 0, y[x], x]


y[x] → ⅇ 1 + ⅇ  2 
-3 x 2x
Out[19]=

Question 4: Solve second order differential equation 4 (d^2


y)/dx^2+12 dy/dx+9y=0

Solution:

In[20]:= DSolve [4 y '' [x] + 12 y '[x] + 9 y[x] ⩵ 0, y[x], x]


x2 x2
y[x] → ⅇ 1 + ⅇ x  2 
-3 -3
Out[20]=

Question 5: Solve second order differential equation (d^2


y)/dx^2-6 dy/dx+13y=0.

Solution:
In[21]:= DSolve [ y '' [x] - 6 y '[x] + 13 y[x] ⩵ 0, y[x], x]
y[x] → ⅇ  2 Cos [2 x] + ⅇ  1 Sin [2 x]
3x 3x
Out[21]=

Question 6: Solve second order differential equation (d^2


y)/dx^2-2 dy/dx+y=0.

Solution:

In[22]:= DSolve [ y '' [x] - 2 y '[x] + y[x] ⩵ 0, y[x], x]


{{y[x] → ⅇ  1 + ⅇ x  2 }}
x x
Out[22]=

Plotting Of Solutions of second order Differential


Equations

Question 1: Solve second order differential equation (d^2


y)/dx^2+y=0 and plot its three solutions.
3

Solution:
In[23]:= Needs ["PlotLegends` "]

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 },
PlotStyle → {{Red, Thickness [0.01 ]}, {Green , Thick }, {Purple , Thickness [0.02 ]}},
PlotLegend → {sol1, sol2, sol3 }]

Out[24]= {{y[x] →  1 Cos [x] +  2 Sin [x]}}

Out[25]= Cos [x] + 2 Sin [x]

Cos [x]
Out[26]= + 5 Sin [x]
2

Out[27]= - Cos [x] - 4 Sin [x]

-20 -10 10 20
Out[28]=
2 sin (x) + cos (x)
-2

cos (x)
5 sin (x) + -4
2

-4 sin (x) - cos (x)

Question 2: Solve second order differential equation (d^2


y)/dx^2+dy/dx-6y=0 and plot its three solutions
Solution:
4

In[29]:= 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},
PlotStyle → {{Pink, Thickness [0.01 ]}, {Green , Thick }, {Orange , Thickness [0.02 ]}},
PlotLegend → {Sol1, Sol2, Sol3 }]

y[x] → ⅇ 1 + ⅇ  2 
-3 x 2x
Out[29]=

Out[30]= 2.5 ⅇ 2 x

ⅇ +5ⅇ
-3 x 2x
Out[31]=

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

150

100

50

Out[33]=
2.5 ⅇ
2x
-2 -1 1 2

-50
ⅇ +5ⅇ
-3 x 2x

-100
1
5ⅇ ⅇ
2x -3 x
-
2

Question 3: Solve second order differential equation 4 (d^2


y)/dx^2+12 dy/dx+9y=0 and plot its four solutions for
(i) C[1]=-1,C[2]=4
(ii) C[1]=3,C[2]=6
(iii) C[1]=-10,C[2]=7
(iv) C[1]=-1.5,C[2]=-5

Solution:
5

In[34]:= 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},
PlotStyle → {{Pink, Thickness [0.01 ]}, {Green , Thick }, {Orange , Thickness [0.02 ]},
{ Purple , Thickness [0.03 ]}} , PlotLegend → {Sol1, Sol2, Sol3, Sol4 }]
x2 x2
y[x] → ⅇ 1 + ⅇ x  2 
-3 -3
Out[34]=

x2 x2
-ⅇ +4ⅇ
-3 -3
Out[35]= x

Out[36]= 3 ⅇ- 3 x2 + 6 ⅇ- 3 x2 x


x2 x2
- 10 ⅇ +7ⅇ
-3 -3
Out[37]= x
x2 x2
- 1.5 ⅇ -5ⅇ
-3 -3
Out[38]= x

50

-2 -1 1 2

4ⅇ x-ⅇ
Out[39]= -3 x2 -3

-50
6ⅇ x+3ⅇ
-3 x2

7ⅇ
-3 x2
x - 10
-100

-5 ⅇ
-3 x2
x - 1.5

Question 4: Solve second order differential equation 4 (d^2


y)/dx^2-6 dy/dx+13y=0 and plot its any three solutions.

Solution:
6

In[40]:= 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},
PlotStyle → {{Pink, Thickness [0.01 ]}, {Green , Thick }, {Orange , Thickness [0.01 ]}},
PlotRange → All, PlotLegend → {sol1, sol2, sol3 }]

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

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

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

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

100

-4 -2 2 4

-100

-200
Out[44]=
2 sin (x) + cos (x)
-300

cos (x)
-400
5 sin (x) +
2
-500

-4 sin (x) - cos (x)

Question 5: Solve second order differential equation (d^2


y)/dx^2-2 dy/dx+y=0 and plot its any five solutions.

Solution:
7

In[45]:= 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}, PlotStyle →
{ Thickness [0.01 ], Thick , Thickness [0.02 ], Thickness [0.03 ], Thickness [0.04 ]} ,
PlotLegend → {Sol1, Sol2, Sol3, Sol4, Sol5 }]

{{y[x] → ⅇ  1 + ⅇ x  2 }}
x x
Out[45]=

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

-3 ⅇ - 2 ⅇ x
x x
Out[47]=

-ⅇ + 7 ⅇ x
x x
Out[48]=

-6 ⅇ + ⅇ x
x x
Out[49]=

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

100

50

3 ⅇ x + 0.5
x
Out[51]= -4 -2 2 4

-2 ⅇ x - 3 ⅇ
x

-50
7ⅇ x-ⅇ
x x

ⅇ x-6ⅇ
x x

2ⅇ xx
ⅇx
+
3 5

Question 6: Solve second order differential equation x^2d^2


y/dx^2-x dy/dx+y=2log(x) and plot its any five solutions.

Solution:
8

In[124]:= Sol = DSolve [x ^ 2 y '' [x] - x y '[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 } , PlotLegends → { Sol1, Sol2, Sol3, Sol4, Sol5 } ]

Out[124]= {{y[x] → x  1 + x  2 Log [x] + 2 × (2 + Log [x])}}

Out[125]= 0.5 x + 3 x Log [x] + 2 × (2 + Log [x])

Out[126]= - 3 x - 2 x Log [x] + 2 × (2 + Log [x])

Out[127]= - x + 7 x Log [x] + 2 × (2 + Log [x])

Out[128]= - 6 x + x Log [x] + 2 × (2 + Log [x])

x 2
Out[129]= + x Log [x] + 2 × (2 + Log [x])
5 3
300

200
0.5 x + 3 x log(x) + 2 (log(x) + 2)
-3 x - 2 x log(x) + 2 (log(x) + 2)

Out[130]=
100 -x + 7 x log(x) + 2 (log(x) + 2)
-6 x + x log(x) + 2 (log(x) + 2)
x 2
-15 -10 -5 5 10 15 + x log(x) + 2 (log(x) + 2)
5 3

-100

Question 7 : Solve second order differential equation x^2d^2


y/dx^2+y=3x^2 and plot its any five solutions.
9

In[145]:= Sol = DSolve [x ^ 2 y '' [x] + y[x] ⩵ 3 x ^ 2, y[x], x]


Sol1 = Evaluate [y[x] / . Sol 〚 1〛 / . {C[1] → 0.5, C[2] → 3}]
Sol2 = y[x] / . Sol 〚 1〛 / . {C[1] → - 2, C[2] → - 2}
Sol3 = y[x] / . Sol 〚 1〛 / . {C[1] → - 1, C[2] → 7}
Sol4 = y[x] / . Sol 〚 1〛 / . {C[1] → - 6, C[2] → 4}
Sol5 = y[x] / . Sol 〚 1〛 / . {C[1] → 5, C[2] → 2 / 3}
Plot [{Sol1, Sol2, Sol3, Sol4, Sol5 },
{ x, - 15, 15 } , PlotLegends → { Sol1, Sol2, Sol3, Sol4, Sol5 } ]
1
Out[145]=  y[x] → x  1 Cos  3 Log [x] +
2
1 1 2 1 2
x  2 Sin  3 Log [x] + x2 Cos  3 Log [x] + Sin  3 Log [x] 
2 2 2
1 1 1 2 1 2
Out[146]= 0.5 x Cos  3 Log [x] + 3 x Sin  3 Log [x] + x2 Cos  3 Log [x] + Sin  3 Log [x]
2 2 2 2
1 1 1 2 1 2
Out[147]= -2 x Cos  3 Log [x] - 2 x Sin  3 Log [x] + x2 Cos  3 Log [x] + Sin  3 Log [x]
2 2 2 2
1 1 1 2 1 2
Out[148]= - x Cos  3 Log [x] + 7 x Sin  3 Log [x] + x2 Cos  3 Log [x] + Sin  3 Log [x]
2 2 2 2
1 1 1 2 1 2
Out[149]= -6 x Cos  3 Log [x] + 4 x Sin  3 Log [x] + x2 Cos  3 Log [x] + Sin  3 Log [x]
2 2 2 2
1 2 1 1 2 1 2
Out[150]= 5 x Cos  3 Log [x] + x Sin  3 Log [x] + x2 Cos  3 Log [x] + Sin  3 Log [x]
2 3 2 2 2

250

1 1
3 x sin 3 log(x) + 0.5 x cos
200 2 2

1 1
-2 x sin 3 log(x) - 2 x cos
2 2
150
1 1
Out[151]= 7 x sin 3 log(x) - x cos 3
2 2
100
1 1
4 x sin 3 log(x) - 6 x cos
2 2
50 2 1 1
x sin 3 log(x) + 5 x cos
3 2 2

-15 -10 -5 5 10 15

Question 8 : Solve second order differential equation d^2


y/dx^2=√ 1+(dy/dx)^2 and plot its any five solutions.
10

In[166]:= Sol = DSolve [ y '' [x] ⩵ Sqrt [1 + ( y '[x]) ^ 2 ], y[x], x]


Sol1 = Evaluate [y[x] / . Sol 〚 1〛 / . {C[1] → 0.5, C[2] → 3}]
Sol2 = y[x] / . Sol 〚 1〛 / . {C[1] → - 2, C[2] → - 2}
Sol3 = y[x] / . Sol 〚 1〛 / . {C[1] → - 1, C[2] → 7}
Sol4 = y[x] / . Sol 〚 1〛 / . {C[1] → - 6, C[2] → 4}
Sol5 = y[x] / . Sol 〚 1〛 / . {C[1] → 5, C[2] → 2 / 3}
Plot [{Sol1, Sol2, Sol3, Sol4, Sol5 },
{ x, - 15, 15 } , PlotLegends → { Sol1, Sol2, Sol3, Sol4, Sol5 } ]

Out[166]= {{y[x] →  2 + Cosh [x] × Cosh [ 1 ] + Sinh [x] × Sinh [ 1 ]}}

Out[167]= 3 + 1.12763 Cosh [x] + 0.521095 Sinh [x]

Out[168]= - 2 + Cosh [2] × Cosh [x] - Sinh [2] × Sinh [x]

Out[169]= 7 + Cosh [1] × Cosh [x] - Sinh [1] × Sinh [x]

Out[170]= 4 + Cosh [6] × Cosh [x] - Sinh [6] × Sinh [x]

2
Out[171]= + Cosh [5] × Cosh [x] + Sinh [5] × Sinh [x]
3

600 000

500 000
0.521095 sinh(x) + 1.12763 cosh(x) + 3
400 000 -sinh(2) sinh(x) + cosh(2) cosh(x) - 2

Out[172]= 300 000


-sinh(1) sinh(x) + cosh(1) cosh(x) + 7
-sinh(6) sinh(x) + cosh(6) cosh(x) + 4
200 000
2
sinh(5) sinh(x) + cosh(5) cosh(x) +
3
100 000

-15 -10 -5 5 10 15

Question 9 : Solve second order differential equation


(1+x^2)d^2 y/dx^2+1+(dy/dx)^2=0 and plot its any five
solutions.
11

In[173]:= Sol = DSolve [(1 + x ^ 2) y '' [x] + 1 + ( y '[x]) ^ 2 ⩵ 0 , y[x], x]


Sol1 = Evaluate [y[x] / . Sol 〚 1〛 / . {C[1] → 0.5, C[2] → 3}]
Sol2 = y[x] / . Sol 〚 1〛 / . {C[1] → - 2, C[2] → - 2}
Sol3 = y[x] / . Sol 〚 1〛 / . {C[1] → - 1, C[2] → 7}
Sol4 = y[x] / . Sol 〚 1〛 / . {C[1] → - 6, C[2] → 4}
Sol5 = y[x] / . Sol 〚 1〛 / . {C[1] → 5, C[2] → 2 / 3}
Plot [{Sol1, Sol2, Sol3, Sol4, Sol5 },
{ x, - 15, 15 } , PlotLegends → { Sol1, Sol2, Sol3, Sol4, Sol5 } ]

y[x] →  2 - x Cot [ 1 ] + Csc [ 1 ] Log [- Cos [ 1 ] - x Sin [ 1 ]]


2
Out[173]=

Out[174]= 3 - 1.83049 x + 4.35069 Log [- 0.877583 - 0.479426 x]


2
Out[175]= - 2 + x Cot [2] + Csc [2] Log [- Cos [2] + x Sin [2]]

Out[176]= 7 + x Cot [1] + Csc [1]2 Log [- Cos [1] + x Sin [1]]

Out[177]= 4 + x Cot [6] + Csc [6]2 Log [- Cos [6] + x Sin [6]]

2 2
Out[178]= - x Cot [5] + Csc [5] Log [- Cos [5] - x Sin [5]]
3

60

-1.83049 x + 4.35069 log(-0.479426 x


40

x cot(2) + csc 2 (2) log(x sin(2) - cos(2)) -


20
Out[179]= x cot(1) + csc 2 (1) log(x sin(1) - cos(1)) +

-15 -10 -5 5 10 15 x cot(6) + csc 2 (6) log(x sin(6) - cos(6)) +

-20 x (-cot(5)) + csc 2 (5) log(x (-sin(5)) - cos

-40

You might also like