0% found this document useful (0 votes)
49 views44 pages

Solutions to Second & Third Order DEs

Uploaded by

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

Solutions to Second & Third Order DEs

Uploaded by

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

Name: Sanjay

Roll No. : 1708


Course : BSc PSC (III year)

PRACTICAL-I
Plotting of second order solution family of differential equation
Solving Second order Ordinary Differential Equation:
2
y
Question 1: Solve second order differential equation d
+y=0.
dx2

Solution:

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


Out[1] {{y[x]→C[1]Cos[x] +C[2]Sin[x]}}
=
d 2y
Question 2: Solve second order differential equation + dy
- 6y=0.
dx2 dx

Solution:

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


Out[3]= y[x]→ ⅇ -3 x C[1] +ⅇ 2 x
C[2]
2
y
Question 3: Solve second order differential equation 4 d
+12 dy
+ 9y=0.
dx 2 dx

Solution:

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


Out[4]= y[x]→ ⅇ -3 x / 2 C[1] +ⅇ - 3 x /2 x C[2]
2
y
Question 4: Solve second order differential equation d
-6 dy
+ 13y=0.
dx2 dx

Solution:

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


Out[5]= y[x]→ ⅇ 3 C[2]Cos[2
x x] +ⅇ C[1]Sin[2 x]
2
y
Question 5: Solve second order differential equation d
-2 dy
+ y=0.
dx2 dx

Solution:

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


Out[6]= y[x]→ ⅇ x C[1] +ⅇ x C[2]

Plotting Of Solutions Of Second Order Differential Equations:


2
y
Question 1: Solve second order differential equation d
+y=0 and plot its three solutions.
dx2
Solution:
2

In[31]:= 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, C[2] ->5}
sol3=y[x] /. Sol[[1]] /.{C[1] -> -1, C[2] -> -4}
Plot[{sol1, sol2, sol3},{x,-10, 10},
PlotStyle-> {{Red, Thickness[0.01]},{Green, Thick},{Purple, Thickness[0.02]}},
PlotLegend→{sol1, sol2, sol3}]
Out[32]= {{y[x]→C[1]Cos[x] +C[2]Sin[x]}}

Out[33]= Cos[x] +2

Sin[x] Out[34]= Cos[x]

+5 Sin[x] Out[35]= -

Cos[x] -4 Sin[x]
4

5 5 10
2 sin(x) +cos(x)
-2
-10
Out[36]=

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

-4 sin(x) -cos(x)

2
y
Question 2: Solve second order differential equation d
+ dy
-6y=0 and plot its three solutions.
dx2 dx

Solution:
3

In[37]:= 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, 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}]
Out[37]= y[x]→ ⅇ -3 x C[1] +ⅇ 2 x
C[2]
2 x
Out[38]= 2.5ⅇ


-3 x 2 x
Out[39]= +5ⅇ
-3 x 2 x
Out[40]= -ⅇ +5ⅇ
200

150

2.5ⅇ 2x 100
1 2

ⅇ-3x +5ⅇ
Out[41]= -50
2x
-2 -1
50
-100
5ⅇ 2x -ⅇ -3x

2
y
Question 3: Solve second order differential equation 4 d
+12 dy
+ 9y=0 and plot its four
solutions for-
dx2 dx

(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:
4

In[60]:= 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}]
Out[60]= y[x]→ ⅇ -3 x/2 C[1] +ⅇ - 3 x /2 x C[2]
-3 x/2 -3 x/2
Out[61]= -ⅇ +4ⅇ
-3 x/2 -3
x Out[62]= 3ⅇ +6ⅇ
x/2 -3 x/2
x Out[63]= -10ⅇ
-3 x/2
+7ⅇ x Out[64]= -1.5ⅇ
-3 x/2 -3 x/2
-5ⅇ x 50

-2 -1 1 2

4ⅇ -3x/2 x-ⅇ -3 -50

6ⅇ -3x/2 x+3ⅇ

-100
Out[65]= 7ⅇ -3x/2 x-10

-5ⅇ -3x/2 x- 1

2
y
Question 4: Solve second order differential equation d
-6 dy
+ 13y=0 and plot its any three
solutions.
dx2 dx

Solution:
5

Sol=DSolve[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}]
Out[66]= y[x]→ ⅇ 3 C[2]Cos[2
x x] +ⅇ C[1]Sin[2 x]

Out[67]= 4ⅇ3 Cos[2


x x] -ⅇ Sin[2 x]

Out[68]= 6ⅇ3 Cos[2


x x] +3ⅇ Sin[2 x]

Out[69]= 7ⅇ3 Cos[2


x x] -10ⅇ

Sin[2
-4
x] -2 2 4

-5.0×10 6

-1.0×10 7

4ⅇ 3x cos(2x) -ⅇ 3x
-1.5×10 7

3ⅇ 3x sin(2x) +6ⅇ 3
-2.0×10 7

Out[70]=
7ⅇ 3x cos(2x) -10

2
y
Question 5: Solve second order differential equation d
-2 dy
+ y=0 and plot its any five
solutions.
dx2 dx

Solution:
6

In[85]:= 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}]
Out[85]= y[x]→ ⅇ x C[1] +ⅇ x C[2]
x x
Out[86]= 0.5ⅇ +3ⅇ xOut[87]=

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

+7ⅇ x
x Out[89]= -6ⅇ x
+ⅇ x

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

100

50

3ⅇ x x+0.5
-2 2 4

-2ⅇ x x-3 ⅇ
Out[91]= -50
-
7ⅇ x x-ⅇ x

ⅇx x-6ⅇ x
2ⅇ x x + ⅇx
35
Plotting of Third Order Solution Family of Differential Equation :

3 2
y y
Question1: Solve third order differential equation d
-5 d
+8 dy
- 4y=0 and plot its any
three
dx3 dx2 dx

solution
s.
Solution
:

In[62]:= Needs["PlotLegends`"]
sol=DSolve[y '''[x] -5 y''[x] +8 y'[x] -4 y[x]⩵0, y[x], x]
sol1=Evaluate y[x] /. sol[[1]] /. C[1]→1, C[2]→0.5, C[3]→2
3
sol2=y[x] /. sol[[1]] /. C[1]→-1 2, C[2]→0, C[3]→1
sol3=y[x] /. sol[[1]] /.{C[1]→-1, C[2]→-4, C[3]→2}
Plot[{sol1, sol2, sol3},{x,-5, 3}, PlotRange-> {-30, 30},
PlotStyle-> {{Red, Thickness[0.01]},{Green, Thick},{Purple,
Thickness[0.02]}}, PlotLegend-> {sol1, sol2, sol3}]
Out[63]= y[x]→ ⅇ x C[1] +ⅇ 2 C[2]
x +ⅇ x C[3]

ⅇx ⅇ
2 x
Out[64]= 2 2 x

+0.5ⅇ + 3
x
ⅇx 2 x
Out[65]=
- +ⅇ
Out[66]= -ⅇx -4ⅇ2 +2ⅇ
x x
30

20

-2 2

2 2xx 10
x+ⅇ +0.5ⅇ -10
3
-
ⅇx
ⅇ2x x-
Out[67]=
-20
2

-30
2ⅇ 2x x-ⅇ x -4ⅇ 2x

3 2
y y
Question2: Solve third order differential equation d
+3 d
-25 dy
+21y=0 and plot its any
four
dx3 dx2 dx

solution
s.
Solution
:
2

In[43]:= sol=DSolve[y '''[x] +3 y ''[x] -25 y'[x] +21 y[x]⩵0, y[x], x]


sol1=Evaluate[y[x] /. sol[[1]] /.{C[1]→1, C[2]→0, C[3]→2}]
sol2=y[x] /. sol[[1]] /. C[1]→-1 2, C[2]→0, C[3]→1
sol3=y[x] /. sol[[1]] /.{C[1]→-1, C[2]→-4, C[3]→2}
sol4=y[x] /. sol[[1]] /.{C[1]→-0.5, C[2]→-2, C[3]→1}
Plot[{sol1, sol2, sol3, sol4},{x,-0.5, 0.5},
PlotStyle-> {{Red, Thickness[0.01]},{Green, Thick},{Purple, Thickness[0.02]},
{Orange, Thickness[0.01]}}, PlotLegend-> {sol1, sol2, sol3, sol4}]
Out[43]= y[x]→ ⅇ -7 x C[1] +ⅇ x
C[2] +ⅇ 3 x
C[3]


-7 x 3 x
Out[44]= +2ⅇ

ⅇ-7 +ⅇ
Out[45]= -
1 3 x
x
2
-7 x x 3 x
Out[46]= -ⅇ -4ⅇ +2ⅇ

Out[47]= -0.5ⅇ -7 x -2ⅇ x


+ⅇ 3 x

20

10

-0.2 0.2 0.4


ⅇ-7x +2ⅇ 3x
-0.4

ⅇ3x - 1 ⅇ-7x
-10
Out[48]=
2

-20
-ⅇ-7x -4ⅇ x +

-0.5ⅇ -7x -2ⅇ

3 2
y y
Question3: Solve third order differential equation d
-4 d
-25 dy
+28y=0 and plot its any
four
dx3 dx2 dx

solution
s.
Solution
:
3

In[49]:= sol=DSolve[y '''[x] -4 y ''[x] -25 y'[x] +28 y[x]⩵0, y[x], x]


sol1=Evaluate[y[x] /. sol[[1]] /.{C[1]→1, C[2]→0, C[3]→2}]
sol2=y[x] /. sol[[1]] /.{C[1]→-2, C[2]→10, C[3]→3}
sol3=y[x] /. sol[[1]] /.{C[1]→-1, C[2]→-4, C[3]→20}
sol4=y[x] /. sol[[1]] /.{C[1]→-0.5, C[2]→-2, C[3]→1}
Plot[{sol1, sol2, sol3, sol4},{x,-0.5, 0.5},
PlotStyle-> {{Red, Thickness[0.01]},{Green, Thick},{Purple, Thickness[0.02]},
{Orange, Thickness[0.01]}}, PlotLegend-> {sol1, sol2, sol3, sol4}]
Out[49]= y[x]→ ⅇ -4 x C[1] +ⅇ x
C[2] +ⅇ 7 x
C[3]


-4 x 7 x
Out[50]= +2ⅇ

Out[51]= -2ⅇ -4 x +10ⅇ x

4 x
+3ⅇ 7 x
Out[52]= -ⅇ - -

4ⅇ x
+20ⅇ 7 x
Out[53]= -

0.5ⅇ -4 x -2ⅇ x
+ⅇ 7 x

80

60

ⅇ-4x +2ⅇ 7x

20
-2ⅇ -4x +10ⅇ x 40

-0.2 0.2 0.4


-ⅇ-4x -4ⅇ x +
Out[54]=
-0.5ⅇ -4x -2ⅇ

3 2
y y
Question4: Solve third order differential equation d
-13 d
+19 dy
+33y=cos(2x) and plot its
any four
dx3 dx2 dx

solution
s.
Solution
:
4

In[55]:= eqn=y'''[x] -13*y ''[x] +19*y '[x] +33 y[x] -Cos[2 x]


sol=DSolve[eqn⩵0, y[x], x]
sol1=Evaluate[y[x] /. sol[[1]] /.{C[1]→1, C[2]→0, C[3]→2}]
sol2=y[x] /. sol[[1]] /.{C[1]→10, C[2]→3, C[3]→6}
sol3=y[x] /. sol[[1]] /.{C[1]→-1, C[2]→-7, C[3]→0.7}
sol4=y[x] /. sol[[1]] /.{C[1]→-10.5, C[2]→2, C[3]→1}
Plot[{sol1, sol2, sol3, sol4},{x, 4, 6},
PlotStyle-> {{Red, Thickness[0.01]},{Green, Thick},{Purple, Thickness[0.02]},
{Orange, Thickness[0.01]}}, PlotLegend-> {sol1, sol2, sol3, sol4}]
(3)[x]
′ ′′
Out[55]= -Cos[2 x] +33 y[x] +19 y [x] -13 y [x] +y

y[x]→ ⅇ -x 17 Cos[2 x] +6 Sin[2 x]


Out[56]= C[1] +ⅇ 3 x
C[2] +ⅇ 11 x
C[3] +
1625

Out[57]= ⅇ-x +2ⅇ 11 x + 17 Cos[2 x] +6 Sin[2 x]


1625

Out[58]= 10ⅇ -x +3ⅇ 3 x +6ⅇ 11 x + 17 Cos[2 x] +6 Sin[2 x]


1625

Out[59]= -ⅇ -x -7ⅇ 3 x +0.7ⅇ 11 x + 17 Cos[2 x] +6 Sin[2 x]


1625

Out[60]= -10.5ⅇ -x +2ⅇ 3 x +ⅇ 11 x + 17 Cos[2 x] +6 Sin[2 x]


1625

4×10 27

3×10 27

ⅇ-x +2ⅇ 11x +

Out[61]= 2×
10ⅇ -x +3ⅇ 3x

-ⅇ-x -7ⅇ 3x +
1× 4.5 5.0 5.5 6.0
-10.5ⅇ -x +2ⅇ

System Of Differential Equations:


Q1. Solve the system of differential equation dx
=2y, dy
= -1
x; x(0)=2, y(0)=1.
dt dt 4

Solution:
5

In[68]:= Sol=DSolve x'[t]⩵2*y[t], y'[t]⩵-1 4*x[t], x[0]⩵2, y[0]⩵1 ,{x[t], y[t]}, t


h1=Plot[{x[t] /. Sol, y[t] /. Sol},{t, 0, 4 Sqrt[2]π}, AxesLabel->
{"t", "x,y"}, PlotStyle-> {Green, Blue}, PlotLegends-> {"x[t]",
"y[t]"}]
h2=ParametricPlot[{x[t], y[t]} /. Sol,{t, 0, 2 Sqrt[2]π}, AxesLabel-> {"X", "Y"}]
Show[GraphicsArray[{h1, h2}]]

Out[68]= x[t]→2 Cos 2 t - 2 t


t + Sin , y[t]→ 2 Sin 2
2
2 t 1
Cos
2 2

x,y

1
5 10 15 x[t]
Out[69]
= -1 t y[t]

-2

-3

1.0

0.5
Out[70]= -3 -2 -1 1 2 3
X
-0.5

-1.0

GraphicsArray : GraphicsArray is obsolete. Switching to GraphicsGrid.

Out[71]=
t X
5 10 15

Q2. Solve the system of differential equation dx


=y, dy
= 1-x 2)y - x; x(0)=1, y(0)=1.
dt dt

Solution:

2 ,
In[76]:= Sol1=NDSolve x'[t]⩵y[t], y'[t]⩵ 1- x[t] *y[t] -x[t], x[0]⩵1, y[0]⩵1
{x[t], y[t]},{t, 0, 30}
k1=Plot[{x[t] /. Sol1, y[t] /. Sol1},{t, 0, 25},
AxesLabel-> {"t", "x,y"}, PlotStyle-> {Blue, Red}]
k2=ParametricPlot[{x[t], y[t]} /. Sol1,{t, 0,
25}, AxesLabel-> {"X", "Y"},
PlotStyle→Dotted]
Show[GraphicsArray[{k1, k2}]]
6

Domain: {{0.,
x[t]→
Out[76]= [t],
30.}}
InterpolatingFunction
Output: scalar

Domain: {{0., [t]


y[t]→
30.}}
InterpolatingFunction
Output: scalar

x,y

1
5 10 15 20 25
Out[77]=
t
-1

-2

Out[78]
-2 -1 1 2
=
X

-1

-2

GraphicsArray : GraphicsArray is obsolete. Switching to GraphicsGrid.


7

x,y
2

2
1
1
Out[79]
= t X
510152025 -2-1 12
-1
-1
-2

-2

Q3. Solve the system of differential equation dx


=y, dy
+5x+2y=1; x(0)=0, y(0)=-1.
dt dt

Solution:

In[80]:= Sol2=DSolve[
{x'[t]⩵y[t], y'[t]⩵-5*x[t] -2*y[t] +1, x[0]⩵0, y[0]⩵-1},{x[t], y[t]}, t]
s1=Plot[{x[t] /. Sol2, y[t] /. Sol2},{t, 0, 3π}, AxesLabel-> {"t",
"x,y"}, PlotStyle-> {Pink, Cyan}, PlotLegends-> {"x[t]",
"y[t]"}]
s2=ParametricPlot[{x[t], y[t]} /. Sol2,{t, 0, 3π},
AxesLabel-> {"X", "Y"}, PlotStyle→Dashed, PlotRange-> {-1, 0.5}]
Show[GraphicsArray[{s1, s2}]]


1 -t
Out[80]= x[t]→ -Cos[2 t] +ⅇ t Cos[2 t]2 -3 Sin[2 t] +ⅇ t Sin[2
, t]2 5
t
y[t]→-ⅇ - Cos[2 t] -Sin[2 t]

x,y

0.4

0.2

x[t]
Out[81]
= 2 4 6 8 y[t]
t
-0.2
8

0.4

0.2

-1.0 -0.5 0.5


X
-0.2

Out[82]= -0.4

-0.6

-0.8

-1.0

GraphicsArray : GraphicsArray is obsolete. Switching to GraphicsGrid.

0.4

0.2
X
-1
.0 -0.5 0.5
Out[83]=
-0.2
t
-0.4

2468 -0.6

-0.8
-1.0
First Order Partial Differential Equation:

∂u ∂u
Q1. Solve the first order PDE x2 +y2 = (x+y)u .
∂x ∂y

In[5]:= DSolve[x ^ 2*D[u[x, y], x] +y ^ 2*D[u[x, y], y]⩵(x+y) *u[x, y], u[x, y],{x, y}]
Out[5]= u[x, y]→x y C[1] -
x y
∂u ∂u
Q2. Solve the first order PDE x +y = u .
∂x ∂y

In[6]:= DSolve[x*D[u[x, y], x] +y*D[u[x, y], y]⩵u[x, y], u[x, y],{x, y}]
Out[6]= u[x, y]→x C[1] y
x
∂u ∂u
Q3. Solve the first order PDE x +y = nu .
∂x ∂y

In[7]:= DSolve[x*D[u[x, y], x] +y*D[u[x, y], y]⩵n*u[x, y], u[x, y],{x, y}]
Out[7]=
y
u[x, y]→x n C[1]
x

Q4. Solve the PDE ux-uy=1, u(x, 0) =x 2


and plot the solution over the domain [-1,1]x[-1,1].

In[8]:= sol=DSolve[{D[u[x, y], x] -D[u[x, y], y]⩵1, u[x, 0]⩵x ^ 2}, u[x, y],{x,
y}] Plot3D[u[x, y] /. sol,{x,-1, 1},{y,-1, 1}]
Out[8]= u[x, y]→x 2 -y+2 x y+y

Out[9]=

Q5. Solve the PDE xux +yu y =xⅇ -u


, u x,x 2
=0 and plot the solution over the domain
[0,2]x[0,2].
2

In[18]:= sol1=DSolve[
{x*D[u[x, y], x] +y*D[u[x, y], y]⩵x*ⅇ^(-u[x, y]), u[x, x ^ 2]⩵0}, u[x, y],
{x, y}] Plot3D[u[x, y] /. sol1,{x, 0, 2},{y, 0, 2}]
Solve: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for
complete solution information.
Solve: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for
complete solution information.
Out[18]= u[x, y]→Log 1+x- y
x

Out[19]=

2
Q6. Solve the PDE yux+xuy=0, u(0,y) =ⅇ -y
and plot the solution over the domain [-1,1]x[-
1,1].
3

sol2=DSolve y*D[u[x, y], x] +x*D[u[x, y], y]⩵0, u[0,


In[16]:=
,
2 u[x, y],{x, y}
y]⩵ⅇ^ -y
Plot3D[u[x, y] /. sol2,{x,-1, 1},{y,-1, 1}]

u[x, y]→ ⅇ
x2 -y2
Out[16]=

Out[17]=

Q7. Solve the PDE xux +yu y =2 xy, u x,x 2


=2 and plot the solution over the domain [1,2]x[-
2,2].

In[20]:= sol3=DSolve[{x*D[u[x, y], x] +y*D[u[x, y], y]⩵2*x*y, u[x, x^ 2]⩵2}, u[x, y],{x,
y}] Plot3D[u[x, y] /. sol3,{x, 1, 2},{y,-2, 2}]
2 x3 +x 4 y-y 3
Out[20]= [
u ]→
x3

Out[21]=

Q8. Solve the PDE ux+xuy=0, u(0,y) =Siny and plot the solution over the domain [-5,5]x[-5,5].
4

In[24]:= sol4=DSolve[{D[u[x, y], x] +x*D[u[x, y], y]⩵0, u[0, y]⩵Sin[y]}, u[x, y],
{x, y}] Plot3D[u[x, y] /. sol4,{x,-5, 5},{y,-5, 5}]
Plot[u[x, y] /. sol4/. x→1,{y,-5, 5}]
Plot[u[x, y] /. sol4/. y→1,{x,-5, 5}]
Out[24]= u[x, y]→Sin 1 -x +2 y
2

Out[25]=

1.0

0.5

Out[26]=
-4 -2 2

-0.5

1.0

0.5

Out[27]=
-4 -2 2

-0.5
5

Q9. Solve the PDE u +xu= y- 1


x2 2, u(0,y) =ⅇ y
and plot the solution over the domain [-
2,2]x[-2,2].
x y 2

In[28]:= sol5=DSolve
D[u[x, y], x] +x*D[u[x, y], y]⩵ y- 1 2 x^ 2 ^2, ,
u[x, y],{x, y}
u[0, y]⩵ⅇ^y

u[x, y]→ 1ⅇ - x 4ⅇ y +ⅇ x x5 - x x3 y+4ⅇ x x y 2


Plot3D[u[x, y] /. sol5,{x,-2, 2},{y,-2, 2}]
2 2
2

2
4ⅇ
2 2 2
Out[28]=
4

Out[29]=

Q10. Solve the PDE uux -uu y =u^ 2+ (x+y) 2, u(x, 0) =1 and plot the solution over
the domain [-2,2]x[-2,2].
6

In[30]:= sol6=DSolve[{u[x, y] *D[u[x, y], x] -u[x, y] *D[u[x, y], y]⩵u ^ 2+ (x+y)^ 2, u[x,
0]⩵1}, u[x, y],{x, y}]
Plot3D[u[x, y] /. sol6,{x,-2, 2},{y,-2, 2}]
Solve: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for
complete solution information.
Solve: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for
complete solution information.
Solve: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for
complete solution information.
General: Further output of Solve::ifun will be suppressed during this calculation.

Out[30]= u[x, y]→- ⅇ-2 y1+x 2 -ⅇ 2 y x2 +2 x y-2ⅇ 2 y ,x y+y 2 -ⅇ 2 y y2


-x 2 -2 x y-y 2 +ⅇ 2 x-2(x+y)1+ (x+y) 2
u[x, y]→

Out[31]=

Q11. Solve the PDE ux +xu y =u+1, u x,x 2


=x 2
and plot the solution over the domain [-
2,2]x[1,5].
7

In[32]:= sol7=
DSolve[{D[u[x, y], x] +x*D[u[x, y], y]⩵u[x, y] +1, u[x, x^ 2]⩵x ^ 2}, u[x, y],
{x, y}] Plot3D[u[x, y] /. sol7,{x,-2, 2},{y, 1, 5}]
-x2+2 y -x2+2 y -x2+2 y
Out[32]= u[x, y]→-1+ⅇ x+ -ⅇ x+ x2 +2ⅇ x+
y

Out[33]=
Finding the Characteristic Equation for First Order PDE and Solving Them:

∂u ∂u
Example1: Find the characteristic curves of the equation x + y =u and plot them.
∂x ∂y
Solution: The characteristic equations dy du
are dx = = .
x y u
Using (i)=(ii) and integrating, we
have, ϕ= y =C , is the first integral.
1
x

Using (i)=(iii) and integrating, we have,


ψ= u =C , is the second integral.
2
x

In[1]:= Plot[{x, 2 x, 3 x},{x,-4, 4}, PlotLegends-> {"y=x", "y=2x", "y=3x"},


Axes→True, AxesLabel-> {"x", "y"}, PlotLabel→"Characteristic Curves"]
Characteristic Curves
y

10

5
y=x
Out[1]
-4 -2 2 4 y=2x
=
x
-5 y=3x

-10
2

In[2]:= Plot[{x, 2 x, 3 x},{x,-4, 4}, PlotLegends-> {"u=x", "u=2x", "u=3x"},


Axes→True, AxesLabel-> {"x", "u"}, PlotLabel→"Characteristic Curves"]
Characteristic Curves
u

10

u=x
Out[2]
-4 -2 2 4 u=2x
=
x
-5 u=3x

-10

In[3]:= Plot3D[{x, 2 x, 3 x},{x,-4, 4},{u,-4, 4}, PlotLegends-> {"y=x", "y=2x",


"y=3x"}, Axes→True, AxesLabel-> {"x", "u", "y"},
PlotLabel→"Characteristic Curves"]

y=x
Out[3]= y=2x
y=3x
3

In[4]:= ParametricPlot3D[{{t, t, u},{t, 2 t, u},{t, 3 t, u}},{t,-5, 5},{u,-4, 4}]

Out[4]=
4

In[5]:= ParametricPlot3D[{{t, y, t},{t, y, 2 t},{t, y, 3 t}},{t,-5, 5},{y,-4, 4}]

Out[5]=

∂u ∂u
Example2: Find the characteristic curves of the equation - =1 and plot them.
∂x ∂y
Solution: The characteristic equations are dx
= dy
= du
.
1 -1 1
Using (i)=(ii) and integrating, we
have, ϕ=x+ y=C 1, is the first
integral.

Using (i)=(iii) and integrating, we have,


ψ=u-x=C 2 , is the second integral.
5

In[6]:= Plot[{1-x, 2-x, 3-x},{x, 0, 3}, PlotLegends-> {"x+y=1", "x+y=2", "x+y=3"},


Axes→True, AxesLabel-> {"x", "y"}, PlotLabel→"Characteristic Curves",
PlotRange-> {0, 3}]
Characteristic Curves
y
3.0

2.5

x+y=
2.0
Out[6] 1
=
x+y=
1.5 2
x+y=
1.0 3

0.5

x
0.0 0.5 1.0 1.5 2.0 2.5 3.0

In[7]:= Plot[{1+x, 2+x, 3+x},{x,-4, 4}, PlotLegends-> {"u-x=1", "u-x=2", "u-x=3"},


Axes→True, AxesLabel-> {"x", "u"}, PlotLabel→"Characteristic Curves"]
Characteristic Curves
u

u-
6
Out[7] x=1
=
4 u-
x=2
2
u-

-4 -2
x=3
2 4

-2 x
6

In[10]:= Plot3D[{1-x, 2-x, 3-x},{x,-4, 4},{u,-4, 4},


PlotLegends-> {"x+y=1", "x+y=2", "x+y=3"}, Axes→True,
AxesLabel-> {"x", "u", "y"}, PlotLabel→"Characteristic
Curves"]

Out[10]=
x+y=1
x+y=2
x+y=3

In[11]:= Plot3D[{1+x, 2+x, 3+x},{x,-4, 4},{y,-4, 4},


PlotLegends-> {"u-x=1", "u-x=2", "u-x=3"}, Axes→True,
AxesLabel-> {"x", "y", "u"}, PlotLabel→"Characteristic
Curves"]

u-
Out[11]= x=1
u-x=2
u-x=3
7

In[12]:= ParametricPlot3D[{{t, 1-t, u},{t, 2-t, u},{t, 3-t, u}},{t,-5, 5},{u,-4, 4}]

Out[12]=

In[13]:= ParametricPlot3D[{{t, y, 1+t},{t, y, 2+t},{t, y, 3+t}},{t,-5, 5},{y,-4, 4}]

Out[13]=
8

∂u ∂u
Example3: Find the characteristic curves of the equation x2 + y2 =(x+y)u and plot them.
∂x ∂y
Solution: The characteristic equations are dx
dy
=(x+y)u
= du
.
x2 y2

Using (i)=(ii) and integrating, we


have, ϕ= y-x =C 1, is the first
x
integral.

Using (i)=(iii) and integrating, we have,


ψ= u =C2, is the second integral.
x
x x x
Plot
In[14]:= , , ,{x,-3, 3}, " y-x y-x y-x
PlotLegends-> =1", " =2", " , =3"
1-x 1-2 x 1-3 x xy xy
xy Axes→ True, AxesLabel-> {"x", "y"}, PlotLabel→ "Characteristic
Curves"

Characteristic Curves
y

0.5

-3 -2 -1 1 2 3 y-x
x xy=1
-0.5 y-x
xy=2
Out[14]
=

-1.0 y-x
xy=3

-1.5
9

In[15]:= Plot3D {x-y, 2(x-y), 3(x-y)},{x,-3, 3},{y,-3, 3},


PlotLegends- " u u u ,
=1", " =2", " Axes→True,
>
=3"
x-y x-y x-y
AxesLabel-> {"x", "y", "u"}, PlotLabel→ "Characteristic Curves"

u
x-y=1
u
Out[15]=
=2
x-y
u
=3
x-y
SOLUTION OF DIFFERENTIAL EQUATION BY VARIATION OF
PARAMETER METHOD:

Solve the equation by variation of parameter-

(a) y''(x) -5y'(x) +6y(x) =2e x

In[1]:= eqn1=D[D[y[x], x], x] -5*D[y[x], x] +6*y[x]⩵0


Out[1]= 6 y[x] -5 ′ y [x] +y [x]⩵0

In[2]:= yc=DSolve[eqn1, y[x], x]


Out[2]= y[x]→ ⅇ 2 C[1]
x +ⅇ C[2]

In[3]:= y1=Exp[2*x]

2 x
Out[3]=

In[4]:= y2=Exp[3*x]

3 x
Out[4]=

In[5]:= w=Wronskian[{y1, y2}, x]



5 x
Out[5]=

In[6]:= r=2*Exp[x]
x
Out[6]= 2ⅇ

In[7]:= v1=Integrate - y2*r w, x


-x
Out[7]= 2ⅇ

In[8]:= v2=Integrate y1*rw, x


-2 x
Out[8]= -ⅇ

In[9]:= yp=y1*v1+y2*v2
Out[9]= ⅇx

In[10]:= Sol=yc+yp
ⅇx + y[x]→ ⅇ
2 x 3 x
Out[10]
= C[1] +ⅇ C[2]

(b) y''(x) +4y(x) =sec 2x

In[45]:= ClearAll[x, y, y1, y2, v1, v2]

In[46]:= eqn2=D[D[y[x], x], x] +4*y[x]⩵0


′′
Out[46]= 4 y[x] +y [x]⩵0
2

In[47]:= yc=DSolve[eqn2, y[x], x]


Out[47]= {{y[x]→C[1]Cos[2 x] +C[2]Sin[2 x]}}

In[48]:= y1=Cos[2 x]
Out[48]= Cos[2 x]

In[49]:= y2=Sin[2 x]
Out[49]= Sin[2 x]

In[50]:= w=Wronskian[{y1, y2}, x]


Out[50]= 2

2
In[51]:= r=Sec x
2
Out[51]= Sec x

In[52]:= v1=Integrate - y2*r w, x

Out[52]= - - 1 1
Sec 2 x Cos[2 x] +
Sin[2 x] 4 8

In[53]:= v2=Integrate y1*r w, x


1 2
Sec 1 Cos[2 x] + 1
Out[53]= x Sin[2 x]
2 4 2

In[54]:= yp= y1*v1 + y2*v2


Out[54]= -Sec Cos[2 - 1 1 + 1 1 1
x] 2 x Cos[2 x] + Sec2 Sin[2 x] Cos[2 x] + x Sin[2 x]
Sin[2 x]

In[55]:= 4 8 2 4 2
Sol=yc+yp
Out[55]= y[x]→C[1]Cos[2 x] +C[2]Sin[2 x]
1 -
1 1 1 1
Sec2 Cos[2 x Cos[2 x] + Sec2 Sin[2 x] Cos[2 x] + x Sin[2 x]
x] - +
Sin[2 x]

(c) y''(x) +y(x) 4 8 2 4 2


=tan(x)

In[56]:= ClearAll[x, y, y1, y2, v1, v2]

In[57]:= eqn3=D[D[y[x], x], x] +y[x]⩵0


Out[57]= y[x] +y′ [x]⩵0

In[68]:= yc=DSolve[eqn3, y[x], x]


Out[68]= {{y[x]→C[1]Cos[x] +C[2]Sin[x]}}

In[69]:= y1=Cos[x]
Out[69]= Cos[x]

In[70]:= y2=Sin[x]
Out[70]= Sin[x]
3

In[71]:= w=Wronskian[{y1, y2}, x]


Out[71]= 1

In[72]:= r=Tan[x]
Out[72]= Tan[x]

In[73]:= v1=Integrate - y2*r w, x


Out[73]= Log Cosx -Sin x -Log Cos x +Sin x +Sin[x]
2 2 2 2

In[74]:= v2=Integrate y1*r w, x


Out[74]= -Cos[x]

In[75]:= yp= y1*v1 + y2*v2


Out[75]= -Cos[x]Sin[x] +Cos[x] Log Cos x -Sinx -Log Cos
x +Sin
x +Sin[x]
2 2 2 2

In[76]:= Sol=yc+yp
Out[76]= y[x]→C[1]Cos[x] +C[2]Sin[x] -Cos[x]Sin[x] +
x x x x
Cos[x] Log Cos -Sin -Log Cos +Sin +Sin[x]
2 2 2 2

(d) y''(x) -2y'(x) =e x


sin x

In[94]:= ClearAll[x, y, y1, y2, v1, v2]

In[95]:= eqn4=D[D[y[x], x], x] -2 D[y[x], x]⩵0


Out[95]= -2 y
′ [x] +y [x]⩵0

In[96]:= yc=DSolve[eqn4, y[x], x]

ⅇ C[1] +C[2]
Out[96]= y[x]→
1 2
x
2

ⅇ2
1 x
In[105]:= y1=

ⅇ2
2
Out[105]=
x

2
In[106]:=
y2=1
Out[106]= 1

In[107]:= w=Wronskian[{y1, y2}, x]


2 x
Out[107]= -ⅇ

x
In[109]:= r=ⅇ Sin[x]
ⅇ Sin[x]
x
Out[109]=

In[110]:= v1=Integrate - y2*r w, x


- ⅇ-
1 x
Out[110]= Cos[x] +Sin[x]
2
4

In[111]:= v2=Integrate y1*r w, x


1
-

Out[111]=
x
-Cos[x] +Sin[x]

In[112]:= yp= y1*v1 + y2*v2


1 1
ⅇ ⅇ
Out[112]= - -Cos[x] Cos[x] +Sin[x]
x x
+Sin[x] -
4 4

In[113]:= Sol=yc+yp

ⅇ C[1]
Out[113]= y[x]→ 1 1 1
ⅇ ⅇ
2
-Cos[x] Cos[x] +Sin[x]
x x
x +C[2] - +Sin[x] -
2 4 4
Plot the Integral Surface of a given First Order PDE with the Initial Data:

Problem 1: Obtain the solution of the linear equation


ux - uy=1,
with the Cauchy data u(x, 0) =x 2.
Plot the integral surface within the range {x,-4,4} and {y,-5,5}.
Solution:

In[1]:= pde=D[u[x, y], x] -D[u[x, y], y]⩵1


0,1) (1,0) [x,
Out[1]= -u ( [x, y] +u y]⩵1

In[2]:= sol=DSolve[{pde, u[x, 0]⩵x ^ 2}, u[x, y],{x, y}]


Out[2]= u[x, y]→x 2 -y+2 x y+y

In[3]:= Plot3D[u[x, y] /. sol,{x,-4, 4},{y,-5, 5}, PlotLabel→"Integral Surface"]

Out[3]=

Problem 2: Obtain the solution of the linear


equation yux - 2xyuy=2xu,
with the Cauchy data u(0,y) =y 3.
Plot the integral surface within the range {x,-7,7} and {y,-5,5}.
Solution:
2

pde=y*D[u[x, y], x] -2*x*y*D[u[x, y],


In[4]:=

y]⩵2*x*u[x, y]
sol2=DSolve[{pde, u[0, y]⩵y ^ 3}, u[x, y],{x, y}]
Plot3D[u[x, y] /. sol2,{x,-7, 7},{y,-5, 5},
PlotLabel→"Integral Surface through initial curve"]
0,1) (1,0) [x,
Out[4]= -2 x y u ( [x, y] +y u y]⩵2 x u[x, y]
2 4
Out[5]= u[x, y]→ x
y

Out[6]=

Problem 3: Obtain the solution of the linear equation


ux + uy =u 2,
with the data x+y=0,u=1.
Plot the integral surface within the range {x,-10,10} and {y,-10,10}.
Solution:
3

In[7]:= Eqn=D[u[x, y], x] +D[u[x, y], y]⩵u[x, y] *u[x, y]


DSolve[{Eqn, u[x,-x]⩵1}, u[x, y],{x, y}]
Plot3D[u[x, y] /.%,{x,-10, 10},{y,-10, 10},
PlotLabel→"Integral Surface through initial curve"]
0,1) (1,0) [x,
Out[7]= u( [x, y] +u y]⩵u[x, y] 2

2
Out[8]= u[x,
y]→- -2+x+y

Out[9]
=

Problem 4: Obtain the solution of the linear equation


ux + uy =1,
with the Cauchy data u(x, 2x) =x 3.
Plot the integral surface within the range {x,-4,4} and {y,-5,5}.
Solution:
4

In[10]:= Eqn1=D[u[x, y], x] +D[u[x, y], y]⩵1


sol=DSolve[{Eqn1, u[x, 2 x]⩵x ^ 3}, u[x, y],{x, y}]
Plot3D[u[x, y] /. sol,{x,-4, 4},{y,-5, 5},
PlotLabel→"Integral Surface through initial curve"]
0,1) (1,0) [x,
Out[10]= u( [x, y] +u y]⩵1

Out[11]= u[x, y]→2 x-x 3-y+3 x 2 y-3 x y


2 +y

Out[12]=

Problem 5: Obtain the solution of the linear


equation u(x+y)ux + u(x-y)u y
=x 2 +y 2,
with the Cauchy data u(x, 2x) =0.
Plot the integral surface within the range {x,-4,4} and {y,-5,5}.
Solution:
5

In[13]:= Eqn2=u[x, y] * (x+y) *D[u[x, y], x] +u[x, y] * (x-y) *D[u[x, y], y]⩵x 2

+y sol=DSolve[{Eqn2, u[x, 2 x]⩵0}, u[x, y],{x, y}]


Plot3D[u[x, y] /. sol,{x,-4, 4},{y,-5, 5},
PlotLabel→"Integral Surface through initial curve"]
Out[13]= (x-y)u[x, y]u (0,1) [x, y] + (x+y)u[x, y]u (1,0) [x, y]⩵x 2
+y 2

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

2
Out[14]= u[x, 2 x2 +3 x y-2 , u[x, y]→ 2 2 x2 +3 x y-2 y 2 ,
y]→- y 2
7
7

u[x, 2 2 2 x2 +3 x y-2 y 2
2 x2 +3 x y-2 , u[x, y]→ 7
y]→- 2
y
7

Out[15]
=

Problem 6: Obtain the solution of the linear equation


ux + u*u y =1,
with the Cauchy data u(0,y) =4* y.
Plot the integral surface within the range {x,-4,4} and {y,-5,5}.
Solution:
6

In[16]:= pde1=D[u[x, y], x] +u[x, y] *D[u[x, y], y]⩵1


sol3=DSolve[{pde1, u[0, y]⩵4*y}, u[x, y],{x, y}]
Plot3D[u[x, y] /. sol3,{x,-4, 4},{y,-5, 5}]
Out[16]= u[x, y]u (0,1) [x, y] +u (1,0) [x, y]⩵1
x+2 x 2
+4 y
Out[17]= [
u ]→
1+4 x

Out[18]=

Problem 7: Obtain the solution of the linear equation


ux + y*u y =0,
with the Cauchy data u(0,y) =4* y.
Plot the integral surface within the range {x,-4,4} and {y,-5,5}.
Solution:
7

In[19]:= pde2=D[u[x, y], x] +y*D[u[x, y], y]⩵0


sol4=DSolve[{pde2, u[0, y]⩵4*y}, u[x, y],{x, y}]
Plot3D[u[x, y] /. sol4,{x,-4, 4},{y,-5, 5}]
0,1) (1,0) [x,
Out[19]= y u( [x, y] +u y]⩵0

Out[20]= u[x, y]→4ⅇ -x y

Out[21]=

Problem 8: Obtain the solution of the linear equation


ux + 2*u y =0,
2
with the Cauchy data u(0,y) =ⅇ -y
.
Plot the integral surface within the range {x,-4,4} and {y,-5,5}.
Solution:
8

In[22]:= pde3=D[u[x, y], x] +2*D[u[x, y], y]⩵0


sol5=DSolve pde3, u[0, y]⩵Exp -y 2 , u[x, y],{x, y}
Plot3D[u[x, y] /. sol5,{x,-4, 4},{y,-5, 5}]
0,1) (1,0) [x,
Out[22]= 2 u( [x, y] +u y]⩵0

u[x, y]→ ⅇ
2
Out[23]= -(-2 x+y)

Out[24]=

You might also like