You are on page 1of 18

Lab Assignment#2

Name: Hussain Ali Murtaza


Class: Master of Science in Chemical and Material
Engineering
Student ID: 202140698
Subject: Advance applied Mathematics

Submitted To: Prof. Boris Golman

Exercise 1: Solve the second-order ODE using the method of variation of parameters
d2 y dy et
−2 ∙ + y=
d t2 dt t 2 +1
Given that:
0∧dy
y ¿t =o= ¿ =1
dt t=o

Solution:
d2 y dy et
−2 ∙ + y= (1)
d t2 dt t 2 +1

 The corresponding Homogenous is :


d2 y dy
2
−2 ∙ + y=0 (2)
dt dt

 Calculate General solution for Homogeneous equation, y h (t )


(a) Calculate A2−4 B
Here A=−2 , B=1
A2−4 B=¿
If A2−4 B=0, the value of y h is:
−A
t
2
y h=e (C 1+ tC 2)

− (− 2) A
t
2
y h=e ( C1 +tC 2 )

Y h=et ( C 1 +tC 2 )

y h (t)=e t C1 +C 2 e t t (3)

Using Eq. (3) in this case the fundamental solutions and their derivatives are:

y 1=et , y '1=e t ¿ y 2=te t , y '2=et + t e t

 Find the Wronskian:

W ( y 1 , y2 ) = y 1 y '2 − y '1 y 2

W ( y 1 , y2 ) =e t (e t +t e t)−e t (tet )

W ( y 1 , y2 ) =e 2 t +t e 2 t−te 2t

W ( y 1 , y2 ) =e 2 t

 Find y p ( t )
y 2 ( t ) . f (t) y ( t ) . f (t )
y p=− y 1∫ + y 1∫ 1
W ( y1 , y2 ) W ( y1 , y2 )
et et
(t e t ). et .
t 2 +1 t 2+ 1
y p=−et ∫ 2t
dt+t e t∫ dt
e e2 t

t 1
y p=−et ∫ 2
dt +t e t∫ 2 dt
t +1 t +1

−e t 2 t t 1
y p= ∫ 2+1
dt +t e ∫ 2 dt
2 t t +1

−et
y p (t)= ¿ (4)
2
 So the general solution for the given ODE
y (t)= y h (t)+ y p (t )
t t et 2 t
y ( t ) =e C 1 +C2 e t− ( ln ( t +1 ) )+ t e (arctan ( t ) ) (5)
2

1 t 2t et d d t
' t t t
y ( t )=e C 1+C 2 e t +C 2 e − e 2
2 ( )
t +1 2
2 t
− ( ln ( t +1 ) ) +e ( arctan ( t ) ) ( t ) +t ( e ( arctan ( t ) ) )
dt dt
t
(t ) e d d
y ' ( t )=et C 1+C 2 et t +C 2 e t −et 2
(t + 1) 2 [
− ( ln ( t 2+1 ) ) + et ( arctan ( t ) ) (1)+t e t ( arctan ( t ) ) + ( arctan ( t ) ) ( e t )
dt dt ]
t t
' t t t t (t ) e 2 t e t
y ( t )=e C 1+C 2 e t +C 2 e −e 2 − ( ln ( t +1 ) ) +e ( arctan ( t ) ) +t 2 +t ( arctan ( t ) ) ( e )
t +1 2 t +1
t
' t t t e 2 t t
y ( t )=e C 1+C 2 e t +C 2 e − ( ln ( t + 1 ) ) +e ( arctan (t ) ) +t ( arctan ( t ) ) ( e )
2
(6)

Now find the value of c1 and c2 putting initial condition in eq (5) and (6):
0∧dy
y ¿t =o= ¿ =1
dt t=o
t t et 2+1 t
y t =e C 1 +C2 e t− ( ln ( t ) )+t e ( arctan ( t ))
( )
2
0 0 e0 0
0=e C 1+ C2 e (0)− ( ln ( 0+1 ) )+( 0)e (arctan ( 0 ))
2
0=C1
C 1=0
t
' t t t e 2 t t
y ( t )=e C 1+C 2 e t +C 2 e − ( ln ( t + 1 ) ) +e ( arctan (t ) ) ++t ( arctan ( t ) ) ( e )
2
0
0 0 0 e 0 0
1=e C1 +C 2 e (0)+C 2 e − ( ln ( 0+1 )) + e ( arctan ( 0 ) ) ++( 0) ( arctan ( 0 ) ) ( e )
2
1=C 1 +C2
Putting C 1=0in above equation:
C 2=1

By putting value of C 1=0and C 2=0in equation(5)


t t et 2 t
y ( t ) =e C 1 +C2 e t− ( ln ( t +1 ) )+ t e (arctan ( t ) )
2
t
t t e 2 t
y ( t ) =e (0)+(1) e t− (ln ( t + 1 ))+t e (arctan ( t ))
2
t
t e 2 t
y ( t ) =e t− (ln ( t +1 ))+t e (arctan ( t ) )
2
Which is the required general solution of given ODE

 Now verify the solution


t et 2 t
y ( t ) =e t− (ln ( t +1 ))+t e (arctan ( t ) )
2
By taking derivative of above equation
' t t et 2 t t
y ( t )=e t +e − ( ln ( t +1 ) ) +e ( arctan ( t ) ) +t ( e ) ( arctan ( t ) )
2
By taking derivative of above equation
1 2t et et d
( )
y ' ' ( t )=e t t+ et + et − e t 2
2 t +1
− ( ln ( t 2 +1 ) ) + et ( arctan ( t )) + 2 +t ( et ) ( arctan ( t ) )+ e t ( arctan ( t ) ) ( t )+ t
2 t +1 dt
t t
t e e
y ( t )=e t+ e + e −e ( +t ( e ) ( arctan ( t ) ) +e ( arctan ( t ) ) (1)+ t [ e
'' t t

t +1 ) t t 2
− ( ln ( t +1 ) ) +e ( arctan ( t ) ) +
2 2
t

t +1 2
t t
d
t

t t t
t e e e
y ( t )=e t+ e + e −e (
'' t t
)
t +1 2
t t 2
− ( ln ( t +1 ) ) +e ( arctan ( t ) ) +
2
t

t +1 2
t t
+t ( e ) ( arctan ( t ) ) +e ( arctan ( t ) ) +t
t +1
+
2

'' t t t et 2 t et t t t
y ( t )=e t+ e + e − ( ln ( t +1 ) ) + e ( arctan ( t ) )+ 2 +t ( e ) ( arctan ( t ) ) +e ( arctan ( t ) ) +t ( arctan ( t ) ) ( e )
2 t +1

 Now putting the value of y ( t ) , y ' ( t ) , y ' ' ( t ) ∈equation1


d2 y dy et
−2 ∙ + y=
d t2 dt t 2 +1
d2 y dy
L.H.S¿ d t 2 −2 ∙ dt + y
t t t et ( 2 ) t et t
e t+ e + e − ( ln t +1 ) +e ( arctan t ) + 2 +t ( e ) ( arctan ( t ) )
( )
2 t +1
t t
+e ( arctan ( t ) ) +t ( arctan ( t ) ) ( e )−2 ¿
t t t et 2 t
+e ( arctan ( t ) ) +t ( e ) ( arctan ( t ) ) ¿ +e t− ( ln ( t +1 ) )+t e (arctan ( t ) )
2

et ( 2 ) t t
t t
¿ e t+ e + e −
t
( ln t +1 ) + e ( arctan ( t ) )+ 2e +t ( e t ) ( arctan ( t ) )
2 t +1
+e t ( arctan ( t ) ) +t ( arctan ( t ) ) ( et )−2 e t t+2 e t +e t ( ln ( t 2 +1 ) )
t t t et 2 t
−2 e ( arctan ( t ) )−2 t ( e ) ( arctan ( t ) ) +e t− (ln ( t +1 ) )+t e (arctan ( t ) )
2

et
¿
t 2 +1
et
R.H.S¿
t 2 +1

L.H.S ¿R.H.S
So, given general solution satisfies the given ODE
Exercise 2: A damped harmonic oscillator is described by the following ODE

d2 y dy
m 2 + c + k . y=0
dt dt
Where m is the mass, c is the damping constant and is the spring constant.
Assume m=1 kg and k =25 N /m

Solution:
d2 y dy
m 2
+ c + k . y=0
dt dt
By putting value of m and k the above equation becomes:
d2 y dy
1. 2
+ c +25. y=0
dt dt

d2 y dy
2
+c +25 y=0
dt
(1)
dt
Case 1: Over damping motion
Select the value of the damping constant c that results in overdamping motion.
Derive the particular solution by hand.
Verify the solution.
d2 y dy
2
+c +25 y=0
dt dt
We assume c=16 in above equation
d2 y dy
2
+16 +25 y=0
dt
(2)
dt
The above equation is second order Homogeneous ODE
 Calculate General solution for Homogeneous equation, y h (t )
(b) Calculate A2−4 B
Here A=16 , B=25
A2−4 B=¿
If A2−4 B=156, the value of y h is:
y h=c1 e λ t +c 2 e λ t
1 2
(3)

Using eq (1) calculate λ 1and λ 2


λ 2+16 λ +25=0
Here a=1 ,b=16 , c=25
−b ± √b 2−4 ac
λ=
2a
−16 ± √ 162−4 (1)(25)
λ=
2(1)
−16 ± √ 156
λ=
2
−16 ±2 √ 39
λ=
2
λ=−8 ± √39
So, λ 1=−8+ √ 39=−¿ λ 2=−8−√ 39=−¿
By putting values of λ 1and λ 2
Y h ( t ) =c 1 e λ t +c 2 e λ t
1 2

y h (t)=c 1 e−¿ ¿
Which is the required general solution of given ODE
 Now verify the solution
y h (t)=c 1 e−¿ ¿
By taking derivative of above equation,
y 'h (t )=−¿
By taking derivative of above equation,
y 'h' ( t )=(−( 8−√ 39 ) )(− ( 8− √39 ) ) c 1 e−¿¿
(−( 8+ √ 39 ) ) c 2 e−( 8+√ 39) t
2 −(8+ 39)t
y 'h' ( t )=(−( 8−√ 39 ) ) c 1 e−¿ ¿ c 2 e √
y 'h' ( t )=64 c 1 e−¿¿
By putting the values of y h ( t ) , y 'h ( t ) , y 'h' ( t ) in equation 2
d2 y dy
2
+16 +25 y=0
dt dt
64 c1 e−¿¿16(−¿
64 c1 e−¿¿
+16 √ 39 c 2 e−( 8+√ 39) t +39 c 2 e− (8+ √39 )t −128 c 1 e−¿ ¿
+128 c 2 e−(8+ √39) t −16 √ 39 c2 e−(8 +√ 39) t +25 c 1 e
−¿ ¿

c 1 e−¿¿
0=0
So, given general solution satisfies the given ODE

Case 2: Critical damping motion


Select the value of the damping constant c that results in critical damping motion.
Derive the particular solution by hand.
Verify the solution.
d2 y dy
2
+c +25 y=0
dt dt
We assume c=10 in above equation
d2 y dy
2
+10 +25 y=0
dt
(4)
dt
The above equation is second order Homogeneous ODE
 Calculate General solution for Homogeneous equation, y h (t )
(c) Calculate A2−4 B
Here A=10 , B=25
A2−4 B=¿
If A2−4 B=0, the value of y h is:
−A
t
2
y h=e (c1 +tc2 )

− ( 10 )
t
2
y h=e ( c 1+ tc2 )
Y h=e−5t ( c 1+tc 2 )

y h (t)=e−5 t c 1+ c 2 e−5 t t

Which is the required general solution of given ODE


 Now verify the solution
y h (t)=e−5 t c 1+ c 2 e−5 t t

By taking derivative of above equation,


y 'h ( t ) =−5 e−5 t c 1+ e−5 t c2−5 c2 e−5 t t
By taking derivative of above equation,
y 'h' ( t )=25 e−5 t c 1−5 e−5 t c 2−5 e−5 t c 2+ 25 c2 e−5 t t
y 'h' ( t )=25 e−5 t c 1−10 e−5 t c 2+ 25 c2 e−5 t t
By putting the values of y h ( t ) , y 'h ( t ) , y 'h' ( t ) in equation 4
d2 y dy
2
+10 +25 y=0
dt dt
25 e c 1−10 e c 2+ 25 c2 e t−50 e−5 t c 1+10 e−5 t c 2−50 c 2 e−5 t t+25 e−5 t c 1+ 25 c 2 e−5 t t=0
−5 t −5 t −5 t

0=0
So, given general solution satisfies the given ODE

Case 3: Under damping motion


Select the value of the damping constant c that results in under damping motion.
Derive the particular solution by hand.
Verify the solution.
d2 y dy
2
+c +25 y=0
dt dt
We assume c=5 in above equation
d2 y dy
2
+5 +25 y=0
dt
(4)
dt
The above equation is second order Homogeneous ODE
 Calculate General solution for Homogeneous equation, y h (t )
(d) Calculate A2−4 B
Here A=5 , B=25
A2−4 B=¿
4 B− A 2 √ 4 (25)−25 √ 75 5 √3
β= √ = = =
2 2 2 2
If A −4 B=0, the value of y h is:
2

−A
t
2
y h=e ( c1 cos ⁡(βt )+c 2 sin ⁡(βt))

−5 −5
t 5 3 t 5 √3
y h=c1 e 2
cos ⁡( √ t )+ c 2 e 2
sin ⁡( t)
2 2

Which is the required general solution of given ODE


 Now verify the solution
−5 −5
t 5 3 t 5 √3
y h=c1 e 2
cos ⁡( √ t )+ c 2 e 2
sin ⁡( t)
2 2

By taking derivative of above equation,

−5 −5
t 5 3 5 3 5 3 −5 5 3 5 3 5 t
(− √ sin √ t )+c 1 (cos √ )( (( √ ) cos ⁡( √ t ))+c sin ⁡( √
−5
'
y ( t ) =c 1 e
h ( ) ( )
2
2 2 ( ) 2 2
e¿¿
2
t)+ c2 e
2 2 2
2

2
−5 −5 −5 −5
−5 3 5 3 5 t 5 3 5 3 5 3 5 5 3 t
y ( t ) = √ c e ( sin ( √ t ))− c e cos ( √ t ) + √ c e ( cos ( √ t )) − c e sin ⁡( √ t)
' t t
2 2 2 2
h 1 1 2 2
2 2 2 2 2 2 2 2
By taking derivative of above equation,
−5 −5
−5 √3 5 3 5 3 5 3 5 3 −5 5
( 5 √23 )sin ( 5 √2 3
t t
(( √ )cos ⁡( √ t))− √ c1 (sin √ )(
−5
''
y ( t )=
h
2
c1 e 2
2 2 2 2 2
e ¿¿
2 2 ( )
t)− c 1 e 2
(−

−5 −5 −5 −5
t 5 3 25 3 t 5 3 25 3 t 5 √3 25 5 3
cos √ t + √ c 1 e sin √ + √ c 1 e t + c 1 e 2 cos √ t
''
y ( t )=
h
−75
4 1
c e 2
( ( ))
2 4
2
( ( ))
2 4
2
(
sin
2 ) 4
t

2 (
−5 −5 −5 −5
t 5 √3 25 3 t 5 √3 25 t 5 √3 25 3 t
5 √3
t + √ c1 e t − √ c2 e
y 'h' ( t )=
−25
2 1
c e 2
( ( ))
cos
2 2
2
( ( ))
sin
2
− c2 e
2
2
( ( ))
sin
2 2
2
cos ( 2

By putting the values of y h ( t ) , y 'h ( t ) , y 'h' ( t ) in equation 4


d2 y dy
2
+5 +25 y=0
dt dt
−5 −5 −5 −5
5 √3 25 3 5 √3 25 5√3 25 3
( 52√3 t )− 25
t t t t
t + √ c1 e t − √ c2 e
−25
2 1
c e 2
( ( ))
cos
2 2
2
( ( ))
sin
2
− c2 e
2
2
( ( ))
sin
2 2
2
cos

0=0
So, given general solution satisfies the given ODE

Exercise 3: Solve the second-order ODE

d2 y dy 85
2
+6 +8 y− cos( t)=0
dt dt 2
Given that:
3∧dy
y ¿t =o= ¿ =5
dt t=o
Solution:

d2 y dy 85
2
+6 +8 y− cos( t)=0
dt dt 2

d2 y dy 85
2
+6 +8 y= cos( t) (1)
dt dt 2
 The corresponding Homogenous is :

d2 y dy
2
+6 +8 y=0 (4)
dt dt
Calculate General solution for Homogeneous equation, y h (t )
(e) Calculate A2−4 B
Here A=6 , B=8
A2−4 B=¿
If A2−4 B=4, the value of y h is:
y h=c1 e λ t +c 2 e λ t
1 2
(3)

Using eq (1) calculate λ 1and λ 2


λ 2+6 λ +8=0
Here a=1 ,b=6 , c=8
−b ± √b 2−4 ac
λ=
2a
−6 ± √ 62 −4 (1)( 8)
λ=
2(1)

−6 ± √36−32
λ=
2
−6 ± √ 4 −16 ±2
λ= =
2 2
λ=−3 ±1
So, λ 1=−3+1=−2∧¿ λ 2=−3−1=−4
By putting values of λ 1and λ 2
y h ( t ) =c 1 e λ t +c 2 e λ t
1 2

y h (t)=c 1 e−2 t + c 2 e−4 t


 Calculate y p (t) with the help of table given below:
y p ( t ) =A sin (t ) + B cos(t )
y p ( t ) =A sin (t ) + B cos(t )
y 'p ( t ) =A cos ( t )−B sin (t)
y 'p' ( t )=− A sin ( t )−B cos(t)
By putting values of y p ( t ) , y 'p ( t ) , y'p' ( t ) ∈equation
d2 y dy 85
2
+6 +8 y= cos( t)
dt dt 2
85
− A sin ( t )−B cos (t)+6 A cos ( t )−6 B sin(t )+ 8 A sin ( t ) +8 B cos(t)= cos (t)
2
85
7 B cos ( t ) +6 A cos (t ) +7 A sin ( t ) −6 B sin ( t )= cos (t)
2
By comparing coefficient of cos(t), and sin(t)
85
7 B+6 A= (i)
2
7 A−6 B=0 (ii)
From eq (ii)
6
7 A=6 B , A= B
7
6
By putting A= 7 B in eq (ii)
6 85
7 B+6( )B=
7 2
36 85
7 B+ B=
7 2
49 B+ 36 B 85
=
7 2
85 B 85
=
7 2
7
B=
2
6 7
So, A= 7 ( 2 )
A=3
By putting value of A and B in the following equation:
y p ( t ) =A sin (t ) + B cos(t )
7
y p ( t ) =3 sin (t ) + cos (t )
2
y ( t ) = yh ( t ) + y p ( t )
7
y ( t ) =c 1 e−2 t + c2 e−4 t + 3 sin ( t ) + cos (t)
2
3∧dy
 Using given condition y ¿t =o= ¿ =5 find the value of c 1and c 2
dt t=o
7
y ( t ) =c 1 e−2 t + c2 e−4 t + 3 sin ( t ) + cos (t) (iii)
2
7
y ' ( t )=−2c 1 e−2t −4 c 2 e−4 t +3 cos ( t )− sin (t) (iv)
2
By putting value y ¿t =o=3 in eq (iii)
7
y ( t ) =−2 c1 e−2 t−4 c 2 e−4 t +3 sin ( t ) + cos (t)
2
7
3=c 1 e−2 (0 )+ c 2 e−4 (0) +3 sin ( 0 ) + cos (0)
2
7
3=c 1+ c 2+ (v)
2
dy
By putting value dt ¿t =o=5 in eq (iv)
7
y ' ( t )=−2c 1 e−2t −4 c 2 e−4 t +3 cos ( t )− sin (t)
2
7
5=−2 c1 −4 c2 +3 cos ( 0 )− sin(0)
2
5=−2 c1 −4 c2 +3

From above eq.


2=−2 c1−4 c 2
1=−c 1−2 c2
c 1=−1−2 c2
By putting value of c 1=−1−2 c2 in eq(v)
7
3=c 1+ c 2+
2
7
3=−1−2 c 2+ c 2+
2
c 2=−1 /2
By putting value of c 2
c 1=−1−2 c2
−1
c 1=−1−2( )
2
c 1=0

Which is the required general solution of given ODE


 Now verify the solution
y h (t)=c 1 e−¿ ¿
By taking derivative of above equation,
y 'h (t )=−¿
By taking derivative of above equation,
y 'h' ( t )=(−( 8−√ 39 ) )(− ( 8− √39 ) ) c 1 e−¿¿
(−( 8+ √ 39 ) ) c 2 e−( 8+√ 39) t
2 −(8+ 39)t
y 'h' ( t )=(−( 8−√ 39 ) ) c 1 e−¿ ¿ c 2 e √
y 'h' ( t )=64 c 1 e−¿¿
By putting the values of y h ( t ) , y 'h ( t ) , y 'h' ( t ) in equation 2
d2 y dy
2
+16 +25 y=0
dt dt
64 c1 e−¿¿16(−¿
64 c1 e−¿¿
+16 √ 39 c 2 e−( 8+√ 39) t +39 c 2 e− (8+ √39 )t −128 c 1 e−¿ ¿
+128 c 2 e−(8+ √39) t −16 √ 39 c2 e−(8 +√ 39) t +25 c 1 e
−¿ ¿

c 1 e−¿¿
0=0
So, given general solution satisfies the given ODE

Tasks:
1. Transform equation in a separable form.
2. Find out the general solution by hand.
3. Use python to calculate integrals from the left-hand and right-hand sides of separable ODE.
4. Write a python program to solve the differential equation in a separable form utilizing dsolve function.
5. Verify the general solution.

Solution:
dy 1+ y 2
+ 2 =0
dx x y (1+ x 2)

dy −1+ y 2
= 2
dx x y (1+ x2 )
------------------(1)

 Thus above equation can be written as separable form

y 2 dy −1
2
= 2
1+ y dx x (1+ x )

y2 −1
2
dy= dx
1+ y ( x+ x3 )
 By integration on B.S of above equation
y2
∫ 1+ y 2 dy=−∫ ( 1 3 ) dx
x+x
2
∫ 1+1+y y−1
2
dy=−∫
1
dx
3 1
(
x 2+x
x
3
)
1+ y 2
∫ 1+ y 2 dy−∫ 1+1y 2 dy =−∫ 1
dx
3 1
( )
x 2 +1
x
1 1
∫ 1 dy−∫ 1+ y 2 dy =−∫ 1
dx
x
3
( )
x2
+1

y−arctany=−I --------------------------(2)

So,
1
I =∫ dx
3 1
( ) x 2 +1
x

Let ( x1 )
u= +1 2

du −2
=
dx x 3

−x 3
dx= du
2
1
I =∫ dx
3 1
( )
x 2 +1
x
−1 1
I= du
2 ∫u
−1
I= ln ⁡¿ )+c
2
−1
I= ln ⁡¿ )+c
2

 By putting value of I in equation (2)

1
y−arctany=−
[ ( )]
−1
2
ln 2 +1 + c
x

1 1+ x 2
y−arctany= ln
2 x2 ( )
+c

1 1
y−arctany= ln ( 1+ x 2 )− ln ( x 2 ) +c
2 2
1 2
y−arctany= ln ( 1+ x 2 )− ln ( x ) +c
2 2
1
y−arctany= ln ( 1+ x 2 )−ln ( x ) +c ----------------(3)
2
The above equation is general solution.
 Verify that solution satisfy the ODE
1
y−arctany= ln ( 1+ x 2 )−ln ( x ) +c
2

By taking derivative of above equation


dy d 1 d
− ( arctan )= ¿
dx dx 2 dx
dy 1 dy 1 1 d
− =
( ) ( 1+ x2 ) − 1 +0
dx 1+ y 2 dx 2 1+ x 2 dx x

1 dy 1 1 1
( 1+ y ) dx 2 ( 1+ x ) x
1− =2
( 2 x )−
2

1+ y 2−1 d y x 1
( 1+ y 2 ) ( )
dx
=
1+ x 2

x

y 2 d y x 2−1−x2
( ) =
1+ y 2 dx x (1+ x 2)

y 2 d y x 2−1−x2
( )2
1+ y dx
= 2
x (1+ x )

y2 d y
( )
1+ y 2
dx
=
−1
x (1+ x 2)

dy −1+ y 2
= 2
dx x y (1+ x 2)
--------------------(4)

By putting value of equation (4) in equation (1)


−1+ y 2 −1+ y 2
= 2 2
x y 2 ( 1+ x 2 ) x y (1+ x )
L . H . S=R . H . S

Exercise 3: Solve the linear ODE


dy
+ y . tanx=sin 2 x for y ( 0 )=1
dx

Tasks:
1. Find the general solution by hand.
2. Find the particular solution by hand.
3. Write a python program to find the general and particular solutions to the original differential equation
utilizing dsolve function.
4. Verify the particular solution.
5. Make a plot in python for the particular solution.

Solution:
dy
+ y . tanx=sin 2 x -------------------(1)
dx
dy
 Compare above equation with standard form ∵
dx
+ P ( x ) . y=Q(x )
dy
+ y . tanx=sin 2 x
dx
P ( x ) =tanx ,Q ( x )=sin(2 x )

 Integrate
sinx
∫ P ( x ) dx=∫ tanx dx=∫ cosx dx=−ln ( cosx )
 Integration Factor
1
e∫ P ( x ) dx=e−ln (cosx )=e ln (cosx ) =(cosx)−1 =
−1

cosx
1
So, I.F=¿ cosx
 Substitute the I.F into following equation
P ( x ) dx
y . e∫ =∫ ( e¿¿ ∫ P ( x ) dx ). Q ( x ) dx +c ¿

1 1
y. =∫ ( ). sin 2 xdx+ c
cosx cosx
1 1
y. ). 2 sinxcosxdx +c
cosx ∫ cosx
= (

1
y. =2 ∫ sinxdx +c
cosx
1
y. =−2 cosx + c
cosx

y=−2cos 2 x +c (cosx) ------------------------------(2)

 Select arbitrary constant c to satisfy the initial conditions y(0)=1


Putting x=0 and y=1 in equation (2) to find value of c

1=−2cos 2 (0)+c (cos ⁡(0))

1=−2(1)+c (1)

1=−2+ c

c=3

 Finally the equation (2) becomes


y=−2cos 2 x +3( cosx)
The above equation is general solution
 Confirm the above solution satisfies the initial condition y(0)=1 by putting x=0 into general
solution

y ( x=0 )=−2cos 2 ( 0 ) +3(cos ⁡(0))

y ( x=0 )=−2(1)+3 (1)

y ( x=0 )=−2+ 3
y ( x=0 )=1

Exercise 4: Solve the Bernoulli’s ODE


dy
y 2 . −5 y 3=e−2 x y ( 0 )=1
dx
Tasks:
1. Find the general solution by hand.
2. Find the particular solution by hand.
3. Write a python program to find the general and particular solutions to the original differential equation
utilizing dsolve function.
4. Verify the particular solution.
5. Make a plot in python for the particular solution.

Solution:
dy
y2 . −5 y 3=e−2 x
dx
 Dividing the above equation by y 2on B.S
dy e−2 x
−5 y= 2
dx y
dy
−5 y=e−2 x . y−2 -----------------------------------(1)
dx
 The equation (1) is Bernoulli’s with
P ( x ) =x 0=1 , R ( x )=e−2 x , α =−2
 A linear equation using change of variables is used
v= y 1−α
1−(−2)
v= y
v= y 3
1
y=v 3
Taking derivative w.r.t x of above equation
−2
dy 1 dv3
= v
dx 3 dx
dy
 By putting values of ‘y’ and dx in equation (1)
−2 1 −2
1 3 dv
v −5 v 3 =e−2 x . v 3
3 dx
−2
 By dividing above equation by v 3 on B.S
1
3
1 dv v
−5 −2 =e−2 x
3 dx
v3
1 dv
−5 v=e−2 x
3 dx
 Multiply above equation by 3
dv
−15 v=3 e−2 x
dx
Which is linear equation
So, P ( x ) =−15 ,Q ( x )=3 e−2 x

 Integrate
∫ P ( x ) dx=∫ −15 dx=−15 x
 Integration Factor
P ( x ) dx
e∫ =e−15 x

 Substitute the I.F into following equation


P ( x ) dx
v . e∫ =∫ (e¿ ¿∫ P ( x ) dx).Q ( x ) dx +c ¿

v . e−15 x =∫ e−15 x .3 e−2 x dx +c

v . e−15 x =3 ∫ e−17 x dx+ c

−3 −17 x
v . e−15 x = e +c
17

 Dividing above equation by e−15 x


−3 e−17 x c
v= −15 x
+ −15 x
17 e e
−3 −2 x c
v= e + −15 x
17 e
−3 −17 x
v= e +c e−15 x
17
 By putting v= y 3 in above equation
−3 −17 x
y 3= e + c e 15 x
17
y=
17
3 −3 e

3 −3 −17 x
e + c e 15 x
−17 x
+17 c e15 x


y=
√ 17
-------------------------------(2)

Select arbitrary constant c to satisfy the initial conditions y(0)=1


Putting x=0 and y=1 in equation (2) to find value of c

−3 e−17 (0) +17 c e15 (0 )


1=

3

3 −3 e
17
−17(0)
+17 c e15 (0 )
1=
√ 0
17
3 −3 e +17 c e
0
1=
√ 17
3 −3 ( 1 )+ 17 c ( 1 )
1=

3 −3+17 c
17

Taking cube on B.S


1=
17 √
¿
−3+17 c
1=
17
17=−3+17 c
20
c=
17
 Finally the equation (2) becomes, by putting value of c
20 15 x
y=

3 −3 e−17 x +17(

−3 e−17 x
17
+20 e15 x
17
)e

y=

3

17
----------------------(3)

The above equation is general solution


 Confirm the above solution satisfies the initial condition y(0)=1 by putting x=0 into general
solution
−3 e−17(0) +20 e 15(0)
y=

3

0
17
3 −3 e + 20 e
0
y=
√ 17
y=

3 −3(1)+20(1)

17
y=

3 −3+20

17
17
y=
3

y= √13
17 √
y ( x=0 )=1

You might also like