0% found this document useful (0 votes)
6 views

pde file

Uploaded by

ujjwal6396
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)
6 views

pde file

Uploaded by

ujjwal6396
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
You are on page 1/ 77

Practical - 1

General solution of first and second order partial


differential equations

First Order Partial Differential Equation


∂u ∂u
Ques. Solve the 1 st Order PDE : x2 + y2 = (x + y) u
∂x ∂y

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}]
-x + y
u[x, y] → x y C[1] 
xy

∂u ∂u
Ques. Solve the 1 st Order PDE : x +y =u
∂x ∂y
2 pde file.nb

DSolve[x * D[u[x, y], x] + y * D[u[x, y], y] ⩵ u[x, y], u[x, y], {x, y}]
y
u[x, y] → x C[1] 
x

∂u ∂u
Ques. Solve the 1 st Order PDE : x +y = nu
∂x ∂y

DSolve[x * D[u[x, y], x] + y * D[u[x, y], y] ⩵ n * u[x, y], u[x, y], {x, y}]
y
u[x, y] → xn C[1] 
x

Ques. Solve the PDE ux - uy = 1,


u (x, 0) = x2 and plot the solution over the domain [-1, 1] x[-1, 1]

sol = DSolve[{D[u[x, y], x] - D[u[x, y], y] ⩵ 1, u[x, 0] == x ^ 2}, u[x, y], {x, y}]
u[x, y] → x2 - y + 2 x y + y2 

Plot3D[u[x, y] /. sol, {x, - 1, 1}, {y, - 1, 1}]

Ques. Solve the PDE xux + yuy = xe-u ,


u x, x2  = 0 and plot the solution over the domain [0, 2] x[0, 2]

sol1 = DSolve[
{x * D[u[x, y], x] + y * D[u[x, y], y] ⩵ x * Exp[- u[x, y]], u[x, x ^ 2] ⩵ 0}, u[x, y], {x, y}]
y
u[x, y] → Log1 + x - 
x
pde file.nb 3

Plot3D[u[x, y] /. sol1, {x, 0, 2}, {y, 0, 2}]

Ques. Solve the PDE yux + xuy = 0,


2
u (0, y) = e-y and plot the solution over the domain [-1, 1] x[-1, 1]

sol2 = DSolve[{y * D[u[x, y], x] + x * D[u[x, y], y] ⩵ 0, u[0, y] ⩵ Exp[- y ^ 2]}, u[x, y], {x, y}]
2
-y2
u[x, y] → ⅇx 

Plot3D[u[x, y] /. sol2, {x, - 1, 1}, {y, - 1, 1}]

Ques. Solve the PDE xux + yuy = 2 xy,


u x, x2  = 2 and plot the solution over the domain [1, 2] x[-2, 2]
4 pde file.nb

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}]
2 x 3 + x4 y - y 3
u[x, y] → 
x3

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

Ques. Solve the PDE ux + xuy = 0,


u (0, y) = Siny and plot the solution over the domain [-5, 5] x[-5, 5]

sol4 = DSolve[{D[u[x, y], x] + x * D[u[x, y], y] ⩵ 0, u[0, y] ⩵ Sin[y]}, u[x, y], {x, y}]
1
u[x, y] → Sin - x2 + 2 y
2

Plot3D[u[x, y] /. sol4, {x, - 5, 5}, {y, - 5, 5}]


pde file.nb 5

Plot[u[x, y] /. sol4 /. x → 1, {y, - 5, 5}]

1.0

0.5

-4 -2 2 4

-0.5

-1.0

Plot[u[x, y] /. sol4 /. y → 1, {x, - 5, 5}]

1.0

0.5

-4 -2 2 4

-0.5

-1.0

1 2
Ques. Solve the PDE ux + xuy = y - , x2
2
u (0, y) = ey and plot the solution over the domain [-2, 2] x[-2, 2]

sol5 = DSolve
D[u[x, y], x] + x * D[u[x, y], y] ⩵ y - x ^ 2  2 ^ 2, u[0, y] ⩵ Exp[y], u[x, y], {x, y}
1 -
x2 x2 x2 x2
u[x, y] → ⅇ 2 4 ⅇy + ⅇ 2 x5 - 4 ⅇ 2 x3 y + 4 ⅇ 2 x y2 
4
6 pde file.nb

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

Ques. Solve the PDE uux - uuy = u2 + (x + y)2 ,


u (x, 0) = 1 and plot the solution over the domain [-2, 2] x[-2, 2]

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}]

u[x, y] → - ⅇ-2 y 1 + x2 - ⅇ2 y x2 + 2 x y - 2 ⅇ2 y x y + y2 - ⅇ2 y y2  ,

u[x, y] → - x2 - 2 x y - y2 + ⅇ2 x-2 (x+y) 1 + (x + y)2  

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

Ques. Solve the PDE ux + xuy = u + 1,


pde file.nb 7

u x, x2  = x2 and plot the solution over the domain [-2, 2] x[1, 5]

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}]
-x2 +2 y -x2 +2 y -x2 +2 y
u[x, y] → - 1 + ⅇx+ - ⅇx+ x2 + 2 ⅇx+ y

Plot3D[u[x, y] /. sol7, {x, - 2, 2}, {y, 1, 5}]

Second Order Partial Differential Equation


To be continue ...

Practical - 2

Solution and plotting of Cauchy problem for first order


PDE’s
Problem : -1
Obtain the solution of the linear equation : u x - uy = 1,
with the Cauchy data u (x, 0) =
x2 .Plot the integral surface with in the range {x, -4, 4} & {y, -5, 5}.

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


- u(0,1) [x, y] + u(1,0) [x, y] ⩵ 1
8 pde file.nb

sol = DSolvepde, u[x, 0] ⩵ x2 , u[x, y], {x, y}


u[x, y] → x2 - y + 2 x y + y2 

Plot3D[u[x, y] /. sol, {x, - 4, 4}, {y, - 5, 5},


PlotLabel → "Integral surface through initial curve"]

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


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

sol = DSolvepde, u[x, 0] ⩵ x2 , u[x, y], {x, y}


u[x, y] → x2 - y + 2 x y + y2 

Plot3D[u[x, y] /. sol, {x, - 4, 4}, {y, - 5, 5}, PlotLabel → "Integral surface"]


pde file.nb 9

Problem : -2
Obtain the solution of the linear equation : yu x - 2 xyuy = 2 xu,
with the Cauchy data u (0, y) =
y3 .Plot the integral surface with in the range {x, -7, 7} & {y, -5, 5}.

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


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

sol3 = DSolvepde, u[0, y] ⩵ y3 , u[x, y], {x, y}


2 3
u[x, y] → ⅇx x2 + y 

Plot3D[u[x, y] /. sol3, {x, - 7, 7}, {y, - 5, 5},


PlotLabel → "Integral surface through initial curve"]

Problem : -3
Determine the integral surfaces of the equation : u x + uy = u2 ,
(a) with the data x + y = 0, u = 1.
(b) with the data u (x, 0) =
tanh (x). Plot the integral surface with in the range {x, -10, 10} &
{y, -10, 10}.

(a)

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


u(0,1) [x, y] + u(1,0) [x, y] ⩵ u[x, y]2

DSolve[{Eqn, u[x, - x] ⩵ 1}, u[x, y], {x, y}]


2
u[x, y] → - 
-2 + x + y
10 pde file.nb

Plot3D[u[x, y] /. %, {x, - 10, 10}, {y, - 10, 10},


PlotLabel → "Integral surface through initial curve"]

b

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


u(0,1) [x, y] + u(1,0) [x, y] ⩵ u[x, y]2

DSolve[{Eqn, u[x, 0] ⩵ Tanh[x]}, u[x, y], {x, y}]


1
u[x, y] → 
- y + Coth[x - y]

Plot3D[u[x, y] /. %, {x, - 10, 10}, {y, - 10, 10},


PlotLabel → "Integral surface through initial curve"]
pde file.nb 11

Problem : -4
Obtain the solution of the linear equation : u x + uy = 1,
with the Cauchy data u (x, 2 x) =
x3 .Plot the integral surface with in the range {x, -4, 4} & {y, -5, 5}.

D[u[x, y], x] + D[u[x, y], y] ⩵ 1


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

sol = DSolveD[u[x, y], x] + D[u[x, y], y] ⩵ 1, u[x, 2 x] ⩵ x3 , u[x, y], {x, y}
u[x, y] → 2 x - x3 - y + 3 x2 y - 3 x y2 + y3 

Plot3D[u[x, y] /. sol, {x, - 4, 4}, {y, - 5, 5}]

Problem : -5
Obtain the solution of the linear equation : u (x + y) u x + u (x - y) uy = x2 + y2 ,
with the Cauchy data u (x, 2 x) =
0. Plot the integral surface with in the range {x, -4, 4} & {y, -5, 5}.

eqn = u[x, y] * (x + y) * D[u[x, y], x] + u[x, y] * (x - y) * D[u[x, y], y] ⩵ x2 + y2


(x - y) u[x, y] u(0,1) [x, y] + (x + y) u[x, y] u(1,0) [x, y] ⩵ x2 + y2

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

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

2 2
u[x, y] → - 2 x2 + 3 x y - 2 y2 , u[x, y] → 2 x2 + 3 x y - 2 y2 
7 7
12 pde file.nb

Plot3D[u[x, y] /. sol, {x, - 4, 4}, {y, - 5, 5}]

Problem : -6
Obtain the solution of the pde : ux + uuy = 1, with the Cauchy data u (0, y) =
4 y. Plot the integral surface with in the range {x, -4, 4} & {y, -5, 5}.

pde4 = D[u[x, y], x] + u[x, y] * D[u[x, y], y] ⩵ 1


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

sol4 = DSolve[{pde4, u[0, y] ⩵ 4 * y}, u[x, y], {x, y}]


x + 2 x2 + 4 y
u[x, y] → 
1+4x

Plot3D[u[x, y] /. sol4, {x, - 4, 4}, {y, - 5, 5}]


pde file.nb 13

Problem : -7
Obtain the solution of the pde : ux + yuy = 0, with the Cauchy data u (0, y) =
4 y. Plot the integral surface with in the range {x, -4, 4} & {y, -5, 5}.

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


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

sol5 = DSolve[{pde5, u[0, y] ⩵ 4 * y}, u[x, y], {x, y}]


u[x, y] → 4 ⅇ-x y

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

Problem : -8
Find the solution of the equation : ux + uy = 0, with the Cauchy data u (0, y) =
2
e-y . Plot the integral surface with in the range {x, -4, 4} & {y, -5, 5}.

pde6 = D[u[x, y], x] + 2 * D[u[x, y], y] ⩵ 0


2 u(0,1) [x, y] + u(1,0) [x, y] ⩵ 0

sol6 = DSolve[{pde6, u[0, y] ⩵ Exp[- y * y]}, u[x, y], {x, y}]


2
u[x, y] → ⅇ-(-2 x+y) 
14 pde file.nb

Plot3D[u[x, y] /. sol6, {x, - 4, 4}, {y, - 5, 5}]

Problem : -9
Determine the integral surface of the equation : u x + uy = u2 ,
with the data u (x, 0) =
tanh (x). Plot the integral surface with in the range {x, -10, 10} &
{y, -10, 10}.

pde7 = D[u[x, y], x] + D[u[x, y], y] ⩵ u[x, y] * u[x, y]


u(0,1) [x, y] + u(1,0) [x, y] ⩵ u[x, y]2

sol7 = DSolve[{pde7, u[x, 0] ⩵ Tanh[x]}, u[x, y], {x, y}]


1
u[x, y] → 
- y + Coth[x - y]
pde file.nb 15

Plot3D[u[x, y] /. %, {x, - 10, 10}, {y, - 10, 10},


PlotLabel → "Integral surface through initial curve"]

Practical - 3

Plotting the characteristics for the first order partial


differential equations.
Example 1 : Find the characteristic curves of the equation xu x + yuy =
u and plot them.
ⅆx ⅆy ⅆu
Solution : The characteristic equations are = = .
x y u
Using (i) = (ii) and integrating we have,
y
ϕ= = C1, is the first integral.
x
Using (i) = (iii) and integrating we have,
u
Ψ= = C2, is the second integral.
x
16 pde file.nb

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
y=2x
x
-4 -2 2 4 y=3x

-5

-10

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

5 u=x
u=2x
x
-4 -2 2 4 u=3x

-5

-10
pde file.nb 17

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
y=2x
y=3x

ParametricPlot3D[{{t, t, u}, {t, 2 t, u}, {t, 3 t, u}}, {t, - 5, 5}, {u, - 4, 4}]
18 pde file.nb

ParametricPlot3D[{{t, y, u}, {t, y, 2 t}, {t, y, 3 t}}, {t, - 5, 5}, {y, - 4, 4}]

Example 2 : Find the characteristic curves of the equation u x - uy =


1 and plot them.
ⅆx ⅆy ⅆu
Solution : The characteristic equations are = = .
1 -1 1
Using (i) = (ii) and integrating we have,
ϕ = x + y = C1, is the first integral.
Using (i) = (iii) and integrating we have,
Ψ = u - x = C2, is the second integral.
pde file.nb 19

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

2.0 x+y=1
x+y=2
1.5
x+y=3
1.0

0.5

x
0.0 0.5 1.0 1.5 2.0 2.5 3.0

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

4 u-x=1
u-x=2
2
u-x=3

x
-4 -2 2 4

-2
20 pde file.nb

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"]

x+y=1
x+y=2
x+y=3

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-x=1
u-x=2
u-x=3
pde file.nb 21

ParametricPlot3D[{{t, 1 - t, u}, {t, 2 - t, u}, {t, 3 - t, u}}, {t, - 5, 5}, {u, - 4, 4}]

ParametricPlot3D[{{t, y, 1 + t}, {t, y, 2 + t}, {t, y, 3 + t}}, {t, - 5, 5}, {y, - 4, 4}]

Example 2 : Find the characteristic curves of the equation x 2 ux + y2 uy =


(x + y) u and plot them.
22 pde file.nb

ⅆx ⅆy ⅆu
Solution : The characteristic equations are = = .
2 2 (x + y) u
x y
Using (i) = (ii) and integrating we have,
y-x
ϕ= = C1, is the first integral.
xy
Using (i) = (iii) and integrating we have,
u
Ψ= = C2, is the second integral.
x-y

x x x y-x y-x y-x


Plot , , , {x, - 3, 3}, PlotLegends → " =1", " =2", " =3",
1-x 1-2x 1-3x xy xy xy
Axes → True, AxesLabel → {"x", "y"}, PlotLabel → "Characteristic Curves"

Characteristic Curves
y

0.5

y-x
x =1
-3 -2 -1 1 2 3
xy
y-x
=2
xy
-0.5
y-x
=3
xy

-1.0

-1.5
pde file.nb 23

Plot3D{x - y, 2 (x - y), 3 (x - y)}, {x, - 3, 3}, {y, - 3, 3},


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

u
=1
x-y
u
=2
x-y
u
=3
x-y

Practical - 4

Solution of vibrating string problem using D’Alembert


formula with initial conditions.

Wave Equation(Infinite String)


utt = c2 uxx , -∞ < x < ∞, t ≥ 0
u (x, 0) = f (x) ∀ x ∈ 
ut (x, 0) = g (x) ∀ x ∈ 
1 1 x+ct
Its solution is given by u (x, t) = [f (x + ct) + f (x - ct)] +  g (τ) ⅆτ
2 2c x-ct
Ques - Solve the wave equation
utt = uxx , ∀ x ∈ , t ≥ 0
Cos3 x, -π2
< x ≤ π2
u (x, 0) =
0 otherwise
ut (x, 0) = 0 , ∀ x ∈ 
24 pde file.nb

c := 1;
-π π -π π
f[x_] := PiecewiseCos[x]3 , ≤x≤ , 0, x < , 0, x > ;
2 2 2 2
g[x_] := 0;
u[x_, t_] :=
1 1
f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}];
2 2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, - 8, 8}, {t, 0, 5}]

1.0

0.8

0.6

Wave at t=0
0.4

0.2

-5 5

0.5

0.4

0.3

Wave at t=1
0.2

0.1

-5 5
pde file.nb 25

0.5

0.4

0.3

Wave at t=2
0.2

0.1

-5 5

0.5

0.4

0.3

Wave at t=3
0.2

0.1

-5 5

0.5

0.4

0.3

Wave at t=4
0.2

0.1

-5 5
26 pde file.nb

0.5

0.4

0.3

Wave at t=5
0.2

0.1

-5 5

1.0 0.5
0.8 0.4
0.6 0.3
ShowGraphicsGrid 0.4 Wave at t=0 , 0.2 Wave at t=1 ,
0.2 0.1
-5 5 -5 5

0.5 0.5
0.4 0.4
0.3 0.3
 0.2 Wave at t=2 , 0.2 Wave at t=3 ,
0.1 0.1
-5 5 -5 5

0.5 0.5
0.4 0.4
0.3 0.3
 0.2 Wave at t=4 , 0.2 Wave at t=5 
0.1 0.1
-5 5 -5 5

Ques - Solve the wave equation


utt = uxx , x ∈ , t ≥ 0
u (x, 0) = Sin (x) ∀ x ∈ 
ut (x, 0) = Cos (x) ∀ x ∈ 
pde file.nb 27

c := 1;
f[x_] := Sin[x];
g[x_] := Cos[x];
u[x_, t_] :=
1 1
f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}];
2 2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, - 8, 8}, {t, 0, 5}]

1.0

0.5

-5 5
Wave at t=0

-0.5

-1.0

1.0

0.5

-5 5
Wave at t=1

-0.5

-1.0
28 pde file.nb

1.0

0.5

-5 5
Wave at t=2

-0.5

-1.0

1.0

0.5

-5 5
Wave at t=3

-0.5

-1.0

1.0

0.5

-5 5
Wave at t=4

-0.5

-1.0
pde file.nb 29

1.0

0.5

-5 5
Wave at t=5

-0.5

-1.0

1.0 1.0
0.5 0.5
ShowGraphicsGrid Wave at t=0 , Wave at t=1 ,
-5 5 -5 5
-0.5 -0.5
-1.0 -1.0

1.0 1.0
0.5 0.5

-5 5
Wave at t=2 , -5 5
Wave at t=3 ,
-0.5 -0.5
-1.0 -1.0

1.0 1.0
0.5 0.5

-5 5
Wave at t=4 , -5 5
Wave at t=5 
-0.5 -0.5
-1.0 -1.0

Ques - Solve the wave equation


utt = π * uxx , x ∈ , t ≥ 0
u (x, 0) = 0 ∀ x ∈ 
2
ut (x, 0) = e-x ∀ x ∈ 
30 pde file.nb

c := Sqrt[N[π]];
f[x_] := 0;
g[x_] := Exp- x2 ;
u[x_, t_] :=
1 1
f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}];
2 2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, - 8, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, - 8, 8}, {t, 0, 5}]

1.0

0.5

-5 5
Wave at t=0

-0.5

-1.0

0.5

0.4

0.3

Wave at t=1
0.2

0.1

-5 5
pde file.nb 31

0.5

0.4

0.3

Wave at t=2
0.2

0.1

-5 5

0.5

0.4

0.3

Wave at t=3
0.2

0.1

-5 5

0.5

0.4

0.3
Wave at t=4

0.2

0.1

-5 5
32 pde file.nb

0.50

0.49

0.48

Wave at t=5
0.47

0.46

0.45

-5 5

1.0 0.5
0.4
0.5 0.3
ShowGraphicsGrid Wave at t=0 , 0.2 Wave at t=1 ,
-5 5
-0.5 0.1
-1.0 -5 5

0.5 0.5
0.4 0.4
0.3 0.3
 0.2 Wave at t=2 , 0.2 Wave at t=3 ,
0.1 0.1
-5 5 -5 5

0.5 0.50
0.4 0.49
0.3 0.48

0.2 Wave at t=4 , 0.47 Wave at t=5 
0.46

-5 5 -5 5

Semi Infinite String with a free end


utt = c2 uxx , 0 < x < ∞, t > 0
u (x, 0) = f (x), 0 ≤ x < ∞
pde file.nb 33

ut (x, 0) = g (x), 0 ≤ x < ∞


ux (0, t) = 0, t ≥ 0
Its solution is given by : u (x, t) =
1 1 x+ct
2
[f (x + ct) + f (x - ct)] + 2c ∫x-ct g (τ) ⅆτ x > ct
1 1 x+ct
2
[f (x + ct) + f (ct - x)] + 2c ∫0 g (τ) ⅆτ x < ct

Ques 1
utt = uxx , 0 < x < ∞, t > 0
ut (x, 0) = 0 , 0 < x < ∞
ux (0, t) = 0 , ∀ t > 0

c := 1;
π
f[x_] := Cos x;
2
g[x_] := 0;
u[x_, t_] := Piecewise
1 1
 f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}], x > c * t,
2 2 * c
1
 f[x + c * t] + f[x - c * t] +
2
1
* Integrate[g[τ], {τ, 0, c * t - x}], x < c * t;;
2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, 0, 8}, {t, 0, 5}]

1.0

0.5

2 4 6 8
Wave at t=0

-0.5

-1.0
34 pde file.nb

1. × 10-15

5. × 10-16

Wave at t=1
1 2 3 4 5 6 7 8

-5. × 10-16

1.0

0.5

3 4 5 6 7 8
Wave at t=2

-0.5

-1.0

1.5 × 10-15

1. × 10-15

5. × 10-16

Wave at t=3
1 2 3 4 5 6 7 8

-5. × 10-16

-1. × 10-15

-1.5 × 10-15

1.0

0.5

5 6 7 8
Wave at t=4

-0.5

-1.0
pde file.nb 35

1.5 × 10-15

1. × 10-15

5. × 10-16

1 2 3 4 5 6 7 8 Wave at t=5
-16
-5. × 10

-1. × 10-15

-1.5 × 10-15

1.0
0.5 1. × 10-15
ShowGraphicsGrid Wave at t=0 , Wave at t=1 ,
-0.5 2 4 6 8 2345678
-1.0

1.0
0.5

3 4 5 6 7 8
Wave at t=2 , 2345678
Wave at t=3 ,
-0.5
-1.0

1.0
0.5

5 6 7 8
Wave at t=4 , 2345678
Wave at t=5 
-0.5
-1.0

Ques 2
utt = uxx , 0 < x < ∞, t > 0
π
u (x, 0) = Cos  x , 0 < x < ∞
2
ut (x, 0) = Sin (x) , 0 < x < ∞
ux (0, t) = 0 , ∀ t > 0
36 pde file.nb

c := 1;
π
f[x_] := Cos x;
2
g[x_] := Sin[x];
u[x_, t_] := Piecewise
1 1
 f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}], x > c * t,
2 2 * c
1
 f[x + c * t] + f[x - c * t] +
2
1
* Integrate[g[τ], {τ, 0, c * t - x}], x < c * t;;
2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, 0, 8}, {t, 0, 5}]

1.0

0.5

2 4 6 8
Wave at t=0

-0.5

-1.0

0.5

2 3 4 5 6 7 8
Wave at t=1

-0.5
pde file.nb 37

2.0

1.5

1.0

0.5

Wave at t=2
3 4 5 6 7 8

-0.5

-1.0

-1.5

0.15

0.10

0.05

4 5 6 7 8
Wave at t=3

-0.05

-0.10

-0.15

1.5

1.0

0.5
Wave at t=4

5 6 7 8

-0.5

-1.0
38 pde file.nb

1.0

0.5

5.5 6.0 6.5 7.0 7.5 8.0


Wave at t=5

-0.5

-1.0

1.0
0.5 0.5
ShowGraphicsGrid Wave at t=0 , Wave at t=1 ,
-0.5 2 4 6 8 2 3 4 5 6 7 8
-0.5
-1.0

2.0 0.15
1.5 0.10
1.0
 Wave at t=2 , 4 5 6 7 8
Wave at t=3 ,
-1.0 3 4 5 6 7 8 -0.10
-1.5 -0.15

1.5 1.0
1.0 0.5
0.5
 Wave at t=4 , Wave at t=5 
5 6 7 8 -0.5 5.56.06.57.07.58.0
-1.0 -1.0

Ques 3
utt = uxx , 0 < x < ∞, t > 0
π
u (x, 0) = Cos  x , 0 < x < ∞
2
-x
ut (x, 0) = e , 0 < x < ∞
ux (0, t) = 0 , ∀ t > 0
pde file.nb 39

c := 1;
π
f[x_] := Cos x;
2
g[x_] := Exp[- x];
u[x_, t_] := Piecewise
1 1
 f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}], x > c * t,
2 2 * c
1
 f[x + c * t] + f[x - c * t] +
2
1
* Integrate[g[τ], {τ, 0, c * t - x}], x < c * t;;
2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, 0, 8}, {t, 0, 5}]

1.0

0.5

2 4 6 8
Wave at t=0

-0.5

-1.0

0.4

0.3

0.2
Wave at t=1

0.1

2 3 4 5 6 7 8
40 pde file.nb

1.5

1.0

0.5

Wave at t=2
3 4 5 6 7 8

-0.5

-1.0

0.5

0.4

0.3

Wave at t=3
0.2

0.1

4 5 6 7 8

1.5

1.0

0.5

Wave at t=4

5 6 7 8

-0.5

-1.0
pde file.nb 41

0.5

0.4

0.3
Wave at t=5
0.2

0.1

0.0 5.5 6.0 6.5 7.0 7.5 8.0

1.0 0.4
0.5 0.3
ShowGraphicsGrid Wave at t=0 , 0.2 Wave at t=1 ,
-0.5 2 4 6 8 0.1
-1.0 2 3 4 5 6 7 8

0.5
1.5 0.4
1.0 0.3
0.5
 Wave at t=2 , 0.2 Wave at t=3 ,
3 4 5 6 7 8 0.1
-1.0
4 5 6 7 8

1.5 0.5
1.0 0.4
0.5 0.3
 Wave at t=4 , 0.2 Wave at t=5 
-0.5 5 6 7 8
-1.0 5.56.06.57.07.58.0

Ques 4
utt = uxx , 0 < x < ∞, t > 0
π
u (x, 0) = Cos  x , 0 < x < ∞
2
-x2
ut (x, 0) = e , 0 < x < ∞
42 pde file.nb

ux (0, t) = 0 , ∀ t > 0

c := 1;
π
f[x_] := Cos x;
2
g[x_] := Exp- x2 ;
u[x_, t_] := Piecewise
1 1
 f[x + c * t] + f[x - c * t] + * Integrate[g[τ], {τ, x - c * t, x + c * t}], x > c * t,
2 2 * c
1
 f[x + c * t] + f[x - c * t] +
2
1
* Integrate[g[τ], {τ, 0, c * t - x}], x < c * t;;
2 * c
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 8}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[u[x, t], {x, 0, 8}, {t, 0, 5}]

1.0

0.5

2 4 6 8
Wave at t=0

-0.5

-1.0

0.4

0.3

Wave at t=1
0.2

0.1

2 3 4 5 6 7 8
pde file.nb 43

1.5

1.0

0.5

Wave at t=2
3 4 5 6 7 8

-0.5

-1.0

0.4

0.3

Wave at t=3
0.2

0.1

4 5 6 7 8

1.5

1.0

0.5

Wave at t=4
5 6 7 8

-0.5

-1.0
44 pde file.nb

0.4

0.3

Wave at t=5
0.2

0.1

5.5 6.0 6.5 7.0 7.5 8.0

1.0 0.4
0.5 0.3
ShowGraphicsGrid Wave at t=0 , 0.2 Wave at t=1 ,
-0.5 2 4 6 8 0.1
-1.0 2 3 4 5 6 7 8

1.5 0.4
1.0 0.3
0.5
 Wave at t=2 , 0.2
0.1
Wave at t=3 ,
-0.5 3 4 5 6 7 8
-1.0 4 5 6 7 8

1.5 0.4
1.0 0.3
0.5
 Wave at t=4 , 0.2
0.1
Wave at t=5 
-0.5 5 6 7 8
-1.0 5.56.06.57.07.58.0

The Vibrating String Problem(Finite String)


utt = c2 uxx , 0 < x < l, t > 0
u (x, 0) = f (x), 0 ≤ x ≤ l
ut (x, 0) = g (x), 0 ≤ x ≤ l
pde file.nb 45

u (0, t) = 0, ∀ t ≥ 0
u (l, t) = 0, ∀ t ≥ 0
Solution :

nπct nπct nπct
u (x, t) =  an Cos + bn Sin Sin
n=1 l l l
2 1 nπx
where an =  f (x) Sin 
 ⅆx
l 0 l
2 1 nπx
bn =  g (x) Sin   ⅆx
nπc 0 l
Ques 1
utt = uxx , 0 < x < 1, t ≥ 0
u (x, 0) = Sin (πx) , 0 ≤ x ≤ l
ut (x, 0) = 3 x + 1 , 0 ≤ x ≤ l
u (0, t) = 0 , ∀ t ≥ 0
u (l, t) = 0 , ∀ t ≥ 0

l := 1;
c := 1;
f[x_] := Sin[π x];
g[x_] := 3 x + 1;
2 nπx
a[n_] := * Integratef[x] * Sin , {x, 0, l};
l l
2 nπx
b[n_] := * Integrateg[x] * Sin , {x, 0, l};
nπc l
nπc nπc n πx
v[x_, t_, n_] := a[n] * Cos t + b[n] * Sin t * Sin ;
l l l
u[x_, t_] := Sum[v[x, t, k], {k, 1, 10}];
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 1}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 1}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 1}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 1}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 1}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 1}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[Evaluate[u[x, t], {x, 0, 1}, {t, 0, 5}]]
46 pde file.nb

1.0

0.8

0.6

Wave at t=0
0.4

0.2

0.2 0.4 0.6 0.8 1.0

0.2 0.4 0.6 0.8 1.0

-0.2

-0.4

Wave at t=1
-0.6

-0.8

-1.0

1.0

0.8

0.6

Wave at t=2
0.4

0.2

0.2 0.4 0.6 0.8 1.0


pde file.nb 47

0.2 0.4 0.6 0.8 1.0

-0.2

-0.4

Wave at t=3
-0.6

-0.8

-1.0

1.0

0.8

0.6

Wave at t=4
0.4

0.2

0.2 0.4 0.6 0.8 1.0

0.2 0.4 0.6 0.8 1.0

-0.2

-0.4

Wave at t=5
-0.6

-0.8

-1.0
48 pde file.nb

1.0
0.8 -0.2 0.20.40.60.81.0
0.6
ShowGraphicsGrid 0.4 Wave at t=0 , -0.4
-0.6 Wave at t=1 ,
0.2 -0.8
-1.0
0.2 0.4 0.6 0.8 1.0

1.0
0.8 -0.2 0.20.40.60.81.0
0.6
 0.4 Wave at t=2 , -0.4
-0.6 Wave at t=3 ,
0.2 -0.8
-1.0
0.2 0.4 0.6 0.8 1.0

1.0
0.8 -0.2 0.20.40.60.81.0
0.6
 0.4 Wave at t=4 , -0.4
-0.6 Wave at t=5 
0.2 -0.8
-1.0
0.2 0.4 0.6 0.8 1.0

Ques 2
utt = 4 uxx , 0 ≤ x ≤ 3, t ≥ 0
π
u (x, 0) = Sin  x , 0 ≤ x ≤ 3
2
ut (x, 0) = Cos (3 x) , 0 ≤ x ≤ 3
u (0, t) = 0 , ∀ t ≥ 0
u (l, t) = 0 , ∀ t ≥ 0
pde file.nb 49

l := 3;
c := 2;
π
f[x_] := Sin x;
2
g[x_] := Cos[3 x];
2 nπx
a[n_] := * Integratef[x] * Sin , {x, 0, l};
l l
2 nπx
b[n_] := * Integrateg[x] * Sin , {x, 0, l};
nπc l
nπc nπc n πx
v[x_, t_, n_] := a[n] * Cos t + b[n] * Sin t * Sin ;
l l l
u[x_, t_] := Sum[v[x, t, k], {k, 1, 10}];
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 3}, PlotRange → All, PlotLegends → "Wave at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 3}, PlotRange → All, PlotLegends → "Wave at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 3}, PlotRange → All, PlotLegends → "Wave at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 3}, PlotRange → All, PlotLegends → "Wave at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 3}, PlotRange → All, PlotLegends → "Wave at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 3}, PlotRange → All, PlotLegends → "Wave at t=5"]
Show[GraphicsArray[{h0, h1}, {h2, h3}, {h4, h5}]]
Plot3D[Evaluate[u[x, t], {x, 0, 1}, {t, 0, 5}]]
1.0

0.5

0.5 1.0 1.5 2.0 2.5 3.0 Wave at t=0

-0.5

-1.0

0.5 1.0 1.5 2.0 2.5 3.0

-0.2

-0.4 Wave at t=1

-0.6

-0.8
50 pde file.nb

0.2

0.5 1.0 1.5 2.0 2.5 3.0

-0.2

-0.4
Wave at t=2
-0.6

-0.8

-1.0

-1.2

1.0

0.5

0.5 1.0 1.5 2.0 2.5 3.0 Wave at t=3

-0.5

-1.0

0.5 1.0 1.5 2.0 2.5 3.0

-0.2

-0.4 Wave at t=4

-0.6

-0.8
pde file.nb 51

0.2

0.5 1.0 1.5 2.0 2.5 3.0

-0.2

-0.4
Wave at t=5
-0.6

-0.8

-1.0

-1.2

1.0
0.5 0.51.01.52.02.53.0
ShowGraphicsGrid Wave at t=0 , -0.4 Wave at t=1 ,
-0.5 0.51.01.52.02.53.0 -0.6
-1.0 -0.8

1.0
0.51.01.52.02.53.0 0.5
 -0.4
-0.6 Wave at t=2 , Wave at t=3 ,
-0.8 -0.5 0.51.01.52.02.53.0
-1.0 -1.0
-1.2

0.51.01.52.02.53.0
 -0.4 Wave at t=4 , -0.4 0.51.01.52.02.53.0 Wave at t=5 
-0.6 -0.6
-0.8
-0.8 -1.0
-1.2

Practical - 5

Solution of heat equation ut= k uxx with initial conditions

Heat Conduction Problem


ut = kuxx , 0 ≤ x ≤ l, t ≥ 0
u (x, 0) = f (x), 0 ≤ x ≤ l
52 pde file.nb

u (0, t) = u (l, t) = 0, ∀ t ≥ 0
u (l, t) = 0, ∀ t ≥ 0
Its Solution -
∞ nπ 2
t nπx
u (x, t) =  an ⅇ-k  l  Sin  
n=l
l
2 1 nπx
where an =  f (x) Sin   ⅆx
l 0 l

Ques 1
ut = uxx , 0 < x < l, t ≥ 0
u (x, 0) = 50 , 0 ≤ x ≤ l
u (0, t) = u (l, t) = 0 , ∀ t ≥ 0

l := 1;
k := 1;
f[x_] := 50;
2 nπx
a[n_] := * Integratef[x] * Sin , {x, 0, l};
l l
nπ 2 n πx
v[x_, t_, n_] := a[n] * Exp- k * * t * Sin ;
l l
u[x_, t_] := Sum[v[x, t, n], {n, 1, 10}];
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 1},
PlotRange → All, PlotLegends → "Heat Equation at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=5"]
Show[GraphicsArray[{{h0, h1}, {h2, h3}, {h4, h5}}]]
Plot3D[Evaluate[u[x, t], {x, 0, 1}, {t, 0, 5}]]
pde file.nb 53

60

50

40

30 Heat Equation at t=0

20

10

0.2 0.4 0.6 0.8 1.0

0.0030

0.0025

0.0020

Heat Equation at t=1


0.0015

0.0010

0.0005

0.2 0.4 0.6 0.8 1.0

1.5 × 10-7

1. × 10-7
Heat Equation at t=2

5. × 10-8

0.2 0.4 0.6 0.8 1.0

8. × 10-12

6. × 10-12

Heat Equation at t=3


4. × 10-12

2. × 10-12

0.2 0.4 0.6 0.8 1.0


54 pde file.nb

4. × 10-16

3. × 10-16

Heat Equation at t=4


2. × 10-16

1. × 10-16

0.2 0.4 0.6 0.8 1.0

2. × 10-20

1.5 × 10-20

Heat Equation at t=5


1. × 10-20

5. × 10-21

0.2 0.4 0.6 0.8 1.0

Heat Equation Heat Equation

0.2 0.4 0.6 0.8 1.0


0.4 0.6 0.8 1.0

Heat Equation Heat Equation

0.2 0.4 0.6 0.8 1.0 0.2 0.4 0.6 0.8 1.0

20
20
Heat Equation
20 Heat Equation
21

0.2 0.4 0.6 0.8 1.0 0.2 0.4 0.6 0.8 1.0
pde file.nb 55

Ques 2
ut = πuxx , 0 ≤ x ≤ l, t ≥ 0
u (x, 0) = Sin (2 x), 0 ≤ x ≤ l
u (0, t) = u (l, t) = 0 , ∀ t ≥ 0

l := 1;
k := π;
f[x_] := Sin[2 x];
2 nπx
a[n_] := * Integratef[x] * Sin , {x, 0, l};
l l
nπ 2 n πx
v[x_, t_, n_] := a[n] * Exp- k * * t * Sin ;
l l
u[x_, t_] := Sum[v[x, t, n], {n, 1, 10}];
h0 = Plot[Evaluate[u[x, 0]], {x, 0, 1},
PlotRange → All, PlotLegends → "Heat Equation at t=0"]
h1 = Plot[Evaluate[u[x, 1]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=1"]
h2 = Plot[Evaluate[u[x, 2]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=2"]
h3 = Plot[Evaluate[u[x, 3]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=3"]
h4 = Plot[Evaluate[u[x, 4]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=4"]
h5 = Plot[Evaluate[u[x, 5]], {x, 0, 1}, PlotRange → All,
PlotLegends → "Heat Equation at t=5"]
Show[GraphicsArray[{{h0, h1}, {h2, h3}, {h4, h5}}]]
Plot3D[Evaluate[u[x, t], {x, 0, 1}, {t, 0, 5}]]
56 pde file.nb

1.2

1.0

0.8

0.6 Heat Equation at t=0

0.4

0.2

0.2 0.4 0.6 0.8 1.0

3.5 × 10-14

3. × 10-14

2.5 × 10-14

2. × 10-14
Heat Equation at t=1
1.5 × 10-14

1. × 10-14

5. × 10-15

0.2 0.4 0.6 0.8 1.0

1.2 × 10-27

1. × 10-27

8. × 10-28

6. × 10-28 Heat Equation at t=2

4. × 10-28

2. × 10-28

0.2 0.4 0.6 0.8 1.0

4. × 10-41

3. × 10-41

2. × 10-41 Heat Equation at t=3

1. × 10-41

0.2 0.4 0.6 0.8 1.0


pde file.nb 57

1.4 × 10-54

1.2 × 10-54

1. × 10-54

8. × 10-55
Heat Equation at t=4
6. × 10-55

4. × 10-55

2. × 10-55

0.2 0.4 0.6 0.8 1.0

4. × 10-68

3. × 10-68

Heat Equation at t=5


2. × 10-68

1. × 10-68

0.2 0.4 0.6 0.8 1.0

14
14
14
14
Heat Equation
14 Heat Equation
14

0.2 0.4 0.6 0.8 1.0


0.2 0.4 0.6 0.8 1.0

Heat Equation Heat Equation

0.2 0.4 0.6 0.8 1.0 0.2 0.4 0.6 0.8 1.0

Heat Equation Heat Equation

0.2 0.4 0.6 0.8 1.0 0.2 0.4 0.6 0.8 1.0
58 pde file.nb

Solution of Heat Equations


Problem - : 1 (a)
ut - uxx = 0, 0 < x < 5, t > 0
u (x, 0) = 0, 0 ≤ x ≤ 5
u (0, t) = Sin (t) , t ≥ 0
u (5, t) = 0 , t ≥ 0
pde file.nb 59

eqn1a = {∂t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ 0, u[0, t] ⩵ Sin[t], u[5, t] ⩵ 0}


sol1a = u[x, t] /. NDSolve[eqn1a, u[x, t], {x, 0, 5}, {t, 0, 10}, PrecisionGoal → 3][[1]]
Plot3D[sol1a, {x, 0, 5}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]
u(0,1) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 0, u[0, t] ⩵ Sin[t], u[5, t] ⩵ 0

Domain: {{0., 5.}, {0., 10.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 1 (b)
ut - uxx = 0, 0 < x < 20, t > 0,
u (x, 0) = 0, 0 ≤ x ≤ 20,
u (0, t) = t2 * Sin (t) , t ≥ 0
u (20, t) = 0 , t ≥ 0
60 pde file.nb

eqn1b = ∂t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ 0, u[0, t] ⩵ t2 * Sin[t], u[20, t] ⩵ 0


sol1b = u[x, t] /. NDSolve[eqn1b, u[x, t], {x, 0, 20}, {t, 0, 10}, PrecisionGoal → 3][[1]]
Plot3D[sol1b, {x, 0, 20}, {t, 0, 10},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]
u(0,1) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 0, u[0, t] ⩵ t2 Sin[t], u[20, t] ⩵ 0

Domain: {{0., 20.}, {0., 10.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 1 (c)
ut - uxx = 0, 0 < x < 20, t > 0
u (x, 0) = 0, 0 ≤ x ≤ 20,
u (0, t) = t2 , t ≥ 0
u (20, t) = 0 , t ≥ 0
pde file.nb 61

eqn1c = ∂t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ 0, u[0, t] ⩵ t2 , u[20, t] ⩵ 0


sol1c = u[x, t] /. NDSolve[eqn1c, u[x, t], {x, 0, 20}, {t, 0, 10}, PrecisionGoal → 3][[1]]
Plot3D[sol1c, {x, 0, 20}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]
u(0,1) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 0, u[0, t] ⩵ t2 , u[20, t] ⩵ 0

Domain: {{0., 20.}, {0., 10.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 2 (a)
ut - uxx = 0, 0 < x < 5, t > 0,
u (x, 0) = Sin (x), 0 ≤ x ≤ 5,
u (0, t) = 1, t ≥ 0
u (5, t) = 0 , t ≥ 0
62 pde file.nb

eqn2a = {∂t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ Sin[x], u[0, t] ⩵ 1, u[5, t] ⩵ 0}


sol2a = u[x, t] /. NDSolve[eqn2a, u[x, t], {x, 0, 5}, {t, 0, 10}, PrecisionGoal → 3][[1]]
Plot3D[sol2a, {x, 0, 5}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,1) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ Sin[x], u[0, t] ⩵ 1, u[5, t] ⩵ 0

Domain: {{0., 5.}, {0., 10.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 2 (b)
ut - uxx = 0, 0 < x < 10, t > 0,
u (x, 0) = Tanh (x), 0 ≤ x ≤ 10,
u (0, t) = t, t ≥ 0
u (10, t) = 0 , t ≥ 0
pde file.nb 63

eqn2b = {∂t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ Tanh[x], u[0, t] ⩵ t, u[10, t] ⩵ 0}


sol2b = u[x, t] /. NDSolve[eqn2b, u[x, t], {x, 0, 10}, {t, 0, 10}, PrecisionGoal → 3][[1]]
Plot3D[sol2b, {x, 0, 10}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,1) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ Tanh[x], u[0, t] ⩵ t, u[10, t] ⩵ 0

Domain: {{0., 10.}, {0., 10.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 2 (c)
ut - 4 uxx = 0, 0 < x < 1, t > 0,
u (x, 0) = x2 (1 - x), 0 ≤ x ≤ 1,
u (0, t) = t, t ≥ 0
u (1, t) = 0 , t ≥ 0
64 pde file.nb

eqn2c = ∂t u[x, t] - 4 * ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ x2 1 - x, u[0, t] ⩵ 0, u[1, t] ⩵ 0


sol2c = u[x, t] /. NDSolve[eqn2c, u[x, t], {x, 0, 1}, {t, 0, 10}, PrecisionGoal → 3][[1]]
Plot3D[sol2c, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,1) [x, t] - 4 u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 1 - x x2 , u[0, t] ⩵ 0, u[1, t] ⩵ 0

Domain: {{0., 1.}, {0., 10.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 3 (a)
ut - 4 uxx = xt, 0 < x < 1, t > 0,
u (x, 0) = Sin (πx), 0 ≤ x ≤ 1,
u (0, t) = t, t ≥ 0
u (1, t) = t2 , t ≥ 0
pde file.nb 65

eqn3a = ∂t u[x, t] - 4 * ∂x,x u[x, t] ⩵ x * t, u[x, 0] ⩵ Sin[π x], u[0, t] ⩵ t, u[1, t] ⩵ t2 
sol3a = u[x, t] /. NDSolve[eqn3a, u[x, t], {x, 0, 1}, {t, 0, 5}, PrecisionGoal → 3][[1]]
Plot3D[sol3a, {x, 0, 1}, {t, 0, 5},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,1) [x, t] - 4 u(2,0) [x, t] ⩵ t x, u[x, 0] ⩵ Sin[π x], u[0, t] ⩵ t, u[1, t] ⩵ t2 

Domain: {{0., 1.}, {0., 5.}}


InterpolatingFunction [x, t]
Output: scalar

Practical - 6

Solution of one - dimensional wave equation with initial


conditions :
i. u(x,0)=f(x), ut(x,0)=g(x), x∈ℝ, t>0
ii. u(x,0)=f(x), ut(x,0)=g(x), u(0,t)=0, x∈ℝ, t>0
iii. u(x,0)=f(x), ut(x,0)=g(x), ux(0,t)=0, x∈ℝ, t>0

Solution of Wave Equations:-


Problem - : 1 (a)
utt - uxx = 0, 0 < x < a, t > 0,
66 pde file.nb

u (x, 0) = Log (1 + x)2 , 0 ≤ x ≤ a,


ut (x, 0) = 2, 0 ≤ x ≤ a
u (1, t) = t2 , t ≥ 0

eqn1a = ∂t,t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ Log1 + x2 , Derivative[0, 1][u][x, 0] ⩵ 2


u(0,2) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ Log1 + x2 , u(0,1) [x, 0] ⩵ 2

sol1a = u[x, t] /. NDSolve[eqn1a, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Plot3D[sol1a, {x, 0, 1}, {t, 0, 4},


AxesLabel → {"x", "" t, "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

Problem - : 1 (b)
utt - uxx = 0, 0 < x < a, t > 0,
u (x, 0) = Sin (x), 0 ≤ x ≤ a,
ut (x, 0) = Cos (x), 0 ≤ x ≤ a
pde file.nb 67

eqn1b = {∂t,t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ Sin[x], Derivative[0, 1][u][x, 0] ⩵ Cos[x]}
sol1b = u[x, t] /. NDSolve[eqn1b, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol1b, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "" t, "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ Sin[x], u(0,1) [x, 0] ⩵ Cos[x]

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 1 (c)
utt - 9 uxx = 0, 0 < x < a, t > 0,
u (x, 0) = e-5 x , 0 ≤ x ≤ a,
ut (x, 0) = xCos (x), 0 ≤ x ≤ a
68 pde file.nb

eqn1c = {∂t,t u[x, t] - 9 * ∂x,x u[x, t] ⩵ 0,


u[x, 0] ⩵ Exp[- 5 x], Derivative[0, 1][u][x, 0] ⩵ Cos[x]}
sol1c = u[x, t] /. NDSolve[eqn1c, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol1c, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - 9 u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ ⅇ-5 x , u(0,1) [x, 0] ⩵ Cos[x]

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 2 (a)
utt - 4 uxx = 0, 0 < x < a, t > 0,
u (x, 0) = 10 * x4 , 0 ≤ x ≤ a,
ut (x, 0) = 0, 0 ≤ x ≤ a
u (0, t) = 0, t ≥ 0
pde file.nb 69

eqn2a = ∂t,t u[x, t] - 4 * ∂x,x u[x, t] ⩵ 0,


u[x, 0] ⩵ 10 x4 , Derivative[0, 1][u][x, 0] ⩵ 0, u[0, t] ⩵ 0
sol2a = u[x, t] /. NDSolve[eqn2a, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol2a, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - 4 u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 10 x4 , u(0,1) [x, 0] ⩵ 0, u[0, t] ⩵ 0

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 2 (b)
utt - 4 uxx = 0, 0 < x < a, t > 0,
u (x, 0) = x4 , 0 ≤ x ≤ a,
ut (x, 0) = 0, 0 ≤ x ≤ a
u (0, t) = 0, t ≥ 0
70 pde file.nb

eqn2b = ∂t,t u[x, t] - 4 * ∂x,x u[x, t] ⩵ 0,


u[x, 0] ⩵ x4 , Derivative[0, 1][u][x, 0] ⩵ 0, u[0, t] ⩵ 0
sol2b = u[x, t] /. NDSolve[eqn2b, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol2b, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - 4 u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ x4 , u(0,1) [x, 0] ⩵ 0, u[0, t] ⩵ 0

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 3 (a)
utt - 9 uxx = 0, 0 < x < a, t > 0,
u (x, 0) = 0, 0 ≤ x ≤ a,
ut (x, 0) = x3 , 0 ≤ x ≤ a
ux (0, t) = 0, t ≥ 0
pde file.nb 71

eqn3a = ∂t,t u[x, t] - 9 * ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ 0,


Derivative[0, 1][u][x, 0] ⩵ x2 , Derivative[1, 0][u][0, t] ⩵ 0
sol3a = u[x, t] /. NDSolve[eqn3a, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol3a, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - 9 u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 0, u(0,1) [x, 0] ⩵ x2 , u(1,0) [0, t] ⩵ 0

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 3 (b)
utt - 4 uxx = 0, 0 < x < a, t > 0,
u (x, 0) = x4 , 0 ≤ x ≤ a,
ut (x, 0) = x3 , 0 ≤ x ≤ a
ux (0, t) = 0, t ≥ 0
72 pde file.nb

eqn3b = ∂t,t u[x, t] - 4 * ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ x4 ,


Derivative[0, 1][u][x, 0] ⩵ x3 , Derivative[1, 0][u][0, t] ⩵ 0
sol3b = u[x, t] /. NDSolve[eqn3b, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol3b, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - 4 u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ x4 , u(0,1) [x, 0] ⩵ x3 , u(1,0) [0, t] ⩵ 0

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 4 (a)
utt - 4 uxx = -9.80665, 0 < x < a, t > 0,
u (x, 0) = 10 x2 (1 - x)2 , 0 ≤ x ≤ a,
ut (x, 0) = 0, 0 ≤ x ≤ a
u (0, t) = u (1, t) = 0, t ≥ 0
pde file.nb 73

eqn4a = ∂t,t u[x, t] - ∂x,x u[x, t] ⩵ - 9.80665, u[x, 0] ⩵ 10 x2 1 - x2 ,


Derivative[0, 1][u][x, 0] ⩵ 0, u[0, t] ⩵ 0, u[1, t] ⩵ 0
sol4a = u[x, t] /. NDSolve[eqn4a, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol4a, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - u(2,0) [x, t] ⩵ - 9.80665,


u[x, 0] ⩵ 10 1 - x2 x2 , u(0,1) [x, 0] ⩵ 0, u[0, t] ⩵ 0, u[1, t] ⩵ 0

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 4 (b)
utt - uxx = 0, 0 < x < a, t > 0,
πx
u (x, 0) = Sin  , 0 ≤ x ≤ a,
2
ut (x, 0) = 0, 0 ≤ x ≤ a
u (0, t) = u (2, t) = 0, t ≥ 0
74 pde file.nb

eqn4b = ∂t,t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ Sinπ * x  2,


Derivative[0, 1][u][x, 0] ⩵ 0, u[0, t] ⩵ 0, u[2, t] ⩵ 0
sol4b = u[x, t] /. NDSolve[eqn4b, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol4b, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

πx
u(0,2) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ Sin , u(0,1) [x, 0] ⩵ 0, u[0, t] ⩵ 0, u[2, t] ⩵ 0
2

Domain: {{0., 2.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Problem - : 4 (c)
utt - uxx = 0, 0 < x < a, t > 0,
u (x, 0) = 0, 0 ≤ x ≤ a,
ut (x, 0) = 8 Sin2 (x), 0 ≤ x ≤ a
u (0, t) = u (π, t) = 0, t ≥ 0
pde file.nb 75

eqn4c = {∂t,t u[x, t] - ∂x,x u[x, t] ⩵ 0, u[x, 0] ⩵ 0,


Derivative[0, 1][u][x, 0] ⩵ x * Sin[π x], u[0, t] ⩵ 0, u[1, t] ⩵ 0}
sol4c = u[x, t] /. NDSolve[eqn4c, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal → 3][[1]]
Plot3D[sol4c, {x, 0, 1}, {t, 0, 4},
AxesLabel → {"x", "t", "u"}, Ticks → {{0, 1, 2, 3, 4}, {0, 1}, {- 3, 0}}]

u(0,2) [x, t] - u(2,0) [x, t] ⩵ 0, u[x, 0] ⩵ 0, u(0,1) [x, 0] ⩵ x Sin[π x], u[0, t] ⩵ 0, u[1, t] ⩵ 0

Domain: {{0., 1.}, {0., 4.}}


InterpolatingFunction [x, t]
Output: scalar

Practical - 7

Solution of traffic flow problem with given initial


conditions, and plotting of the characteristic base curves
and the traffic density function.
To be continue ...

In[ ]:= Question1 : Find the traffic density ρ x, t satisfying


Subscript[ρ, t] + xSint ρx = 0
with initial condition Subscript[ρ, 0] (x) = 1 + 1  1 + x2
Plot the characteristic base curves and the traffic density function.
The characteristic base curves for the given initial value problem are given by :
76 pde file.nb

In[ ]:= charBaseCurves1 = DSolve[{x '[t] == x[t] * Sin[t], x[0] == x0}, x[t], t]
Out[ ]= x[t] → ⅇ1-Cos[t] x0

In[ ]:= tab = Table[x[t] /. charBaseCurves1[[1]] /. {x0 -> k}, {k, 5, 20, 5}]
Plot[Evaluate[tab], {t, - 10, 10}, PlotStyle -> Thickness[0.01],
PlotLegends -> Table[tab[[i]], {i, 1, 4}], PlotLabel -> "characteristic Base Curves"]
Out[ ]= 5 ⅇ1-Cos[t] , 10 ⅇ1-Cos[t] , 15 ⅇ1-Cos[t] , 20 ⅇ1-Cos[t] 

characteristic Base Curves


150

100
5 ⅇ1-cos(t)
10 ⅇ1-cos(t)
Out[ ]=
15 ⅇ1-cos(t)

50
20 ⅇ1-cos(t)

-10 -5 5 10

1
DSolve: Equation or list of equations expected instead of 1 + in the first argument
1 + x2
1
ρ0,1 [x, t] + x Sin[t] ρ1,0 [x, t] ⩵ 0, 1 + .
1 + x2
1
DSolve: Equation or list of equations expected instead of 1 + in the first argument
1 + x2
1
ρ0,1 [x, t] + x Sin[t] ρ1,0 [x, t] ⩵ 0, 1 + .
1 + x2

Que 2. Find the traffic density ρ x, t satisfying


ρt + e t ρx = 2 ρ
with initial condition ρ0 (x) = I + Sin2 (x)
Plot the Characteristic base curves and the traffic density function

In[ ]:= charBaseCurves2 = DSolve[{x '[t] == Exp[t], x[0] == x0}, x[t], t]


Out[ ]= x[t] → - 1 + ⅇt + x0
pde file.nb 77

In[ ]:= tab = Table[x[t] /. charBaseCurves2[[1]] /. {x0 -> k}, {k, 4, 20, 4}]
Plot[Evaluate[tab], {t, - 4, 4}, PlotStyle -> Thickness[0.01],
PlotLegends -> Table[tab[[i]], {i, 1, 5}], PlotLabel -> "characteristic Base Curves"]
Out[ ]= 3 + ⅇt , 7 + ⅇt , 11 + ⅇt , 15 + ⅇt , 19 + ⅇt 

characteristic Base Curves

50

40 ⅇt + 3
ⅇt + 7
30
Out[ ]= ⅇt + 11
ⅇt + 15
20
ⅇt + 19
10

-4 -2 2 4

Que 3. Find the traffic density ρ x, t satisfying


ρt + 2 ρx = 0. with initial condition ρ0(x) = Exp- x2 
Plot the Characteristic base curves and the traffic density function

In[ ]:= charBaseCurves3 = DSolve[{x '[t] == 2, x[0] == x0}, x[t], t]


Out[ ]= {{x[t] → 2 t + x0}}

In[ ]:= tab = Table[x[t] /. charBaseCurves3[[1]] /. {x0 -> k}, {k, 1, 5, 1}]
Plot[Evaluate[tab], {t, - 2, 2}, PlotStyle -> Thickness[0.01],
PlotLegends -> Table[tab[[i]], {i, 1, 5}], PlotLabel -> "characteristic Base Curves"]
Out[ ]= {1 + 2 t, 2 + 2 t, 3 + 2 t, 4 + 2 t, 5 + 2 t}

characteristic Base Curves

6 2t +1
2t +2
4
Out[ ]= 2t +3
2 2t +4
2t +5
-2 -1 1 2

-2

You might also like