PDE Practical 1 - Merged
PDE Practical 1 - Merged
The most general, first-order, partial differential equation in two independent variables x and
y is of the form
F (x, y, u, ux , uy ) = 0, (x, y) ∈ D ⊂ R2
where F is a given function of its arguments, and u = u (x, y) is an unknown function of the
independent variables x and y which lie in some given domain D in R2 , ux =∂u/∂x and uy =∂u/∂y
.Equation is often written interms of standard notation p = ux and q = uy so that takes the form
F (x, y, u, p, q) = 0,
Similarly, the most general, first-order, partial differential equation in three independent
variables x, y, z can be written as
F (x, y, z, u, ux , uy , uz ) = 0.
in which we assume Aij = A ji and Aij , Bi , F , and G are real-valued functions defined in some
region of the space e ( x1 , x2 , ..., xn ).
Here we shall be concerned with second-order equations in the dependent variable u and
the independent variables x, y. Hence equation can be put in the form
Auxx + Buxy + Cuyy + Dux + Euy + Fu = G,
where the coefficients are functions of x and y and do not vanish simultaneously. We shall
assume that the function u and the coefficients are twice continuously differentiable in some
domain in R2 .
PRACTICAL 1
Solution of Cauchy problem for First-Order Partial Differential Equations :
Question1 : xux + yuy = 0
I n [ ] : = eqn1 = x * D[u[x, y], x] + y * D[u[x, y], y] 0;
sol1 = DSolve[eqn1, u[x, y], {x, y}]
O u t [ ] =
y
u[x, y] 1
x
Question 2 : ux = 0
2 Pratical 1 pde.nb
{{u[x, y] 1 [y]}}
Question 3 : ux + yuy = 0
Question 5 : 2xyux + x 2 + y 2 uy = 0
y2
u[x, y] 1 - x +
x
{{u[x, t] 1 [t - x] + 2 [t + x]}}
{{u[x, t] 1 [t + x] + 2 [t - x]}}
Pratical 1 pde.nb 3
Question 2 : ux +2 uy = 0
2
u(0,y) = e(-y)
I n [ ] : = eqn2 = D[u[x, y], x] + 2 * D[u[x, y], y] 0
sol2 = DSolve[{eqn2, u[0, y] Exp[- y ^ 2]}, u[x, y], {x, y}]
O u t [ ] =
Question 3 : ux + uy = 1
u(x,2x) = x 3
I n [ ] : = eqn3 = D[u[x, y], x] + D[u[x, y], y] 1
sol3 = DSolveeqn3, u[x, 2 * x] x3 , u[x, y], {x, y}
O u t [ ] =
u[x, y] 2 x - x3 - y + 3 x2 y - 3 x y2 + y3
Question 4 : yu x + xu y = 0
practil 2 pde.nb 3
2
u(0,y) = e(- y)
I n [ ] : = eqn4 = y * D[u[x, y], x] + x * D[u[x, y], y] 0
2
sol4 = DSolveeqn4, u[0, y] -y , u[x, y], {x, y}
O u t [ ] =
Question 5 : xux + uy = 0
u(x,0) = x 2
I n [ ] : = eqn5 = x * D[u[x, y], x] + D[u[x, y], y] 0
sol5 = DSolveeqn5, u[x, 0] x2 , u[x, y], {x, y}
O u t [ ] =
u[x, y] -2 y x2
4 practil 2 pde.nb
O u t [ ] =
O u t [ ] =
D’Alembert
We shall consider the following Cauchy problem of an infinite string
with the initial condition
utt - c2 uxx = 0, , xϵ ℝ, t > 0, (1)
u(x, 0) = f (x), xϵ ℝ, (2)
ut (x, 0) = g(x), xϵ ℝ. (3)
By the method of characteristics described , the characteristic equation according to equation
dx2 − c2 dt2 = 0
which reduces to
dx + c dt = 0, dx − c dt = 0
The integrals are the straight lines
x + ct = c1 , x − ct = c2
Introducing the characteristic coordinates
ξ = x + ct, η = x − ct,
we obtain
uxx = uξξ + 2 uξη + uηη , utt = c2 (uξξ − 2 uξη + uηη ).
Substitution of these in equation (1) yields
− 4 c2 uξη = 0
Since c =/ 0, we have
uξη = 0.
Integrating with respect to ξ, we obtain
uη = ψ∗(η)
where ψ∗(η) is an arbitrary function of η. Integrating again with respect to η, we obtain
u (ξ,η) = ψ∗(η) dη + ϕ(ξ).
If we set ψ (η) = *ψ∗(η) dη, we have
u (ξ,η) = φ (ξ) + ψ (η),
where φ and ψ are arbitrary functions. Transforming to the original variables x and t, we find
the general solution of the wave equation
u (x, t) = ϕ (x + ct) + ψ (x − ct), (4)
provided φ and ψ are twice differentiable functions. Now applying the initial conditions (2)
and (3), we obtain
u (x, 0) = f (x) = φ (x) + ψ (x), (5)
ut (x, 0) = g (x) = c φ′(x) − c ψ′(x) (6)
Integration of equation (6) gives
1
ϕ(x) − ψ (x) = ∫ g (τ ) dτ + K, (7)
c
where x0 and K are arbitrary constants. Solving for φ and ψ from equations(5) and (7), we
2 PDE Pratical 4.nb
obtain
1 1 K
ϕ(x) = f(x) + ∫ g (τ ) dτ + ,
2 2c 2
1 1 K
ψ(x) = f(x) - ∫ g (τ ) dτ - .
2 2c 2
This is called the celebrated d’Alembert solution of the Cauchy problem for the one-dimen-
sional wave equation.
PRACTICAL 4
Solution of vibrating string problem using D’Alembert formula with initial
conditions :
Question 1 : utt - c2 uxx = 0,
u(x, 0) = f (x), - π/2 ≤ x ≤π/2
ut (x, 0) = g(x), t > 0.
with initial conditions f (x) = Cos( x )3 and g(x) = 0. Take c = 1
PDE Pratical 4.nb 3
I n [ ] : = c = 1;
f[x_] = Which- Pi / 2 ≤ x ≤ Pi / 2, Cos[x]3 , True, 0
u[x_, t_] := (f[x + c * t] + f[x - c * t]) / 2
h0 = Plot[Evaluate[u[x, 0]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 0", LabelStyle Directive[Bold, Blue]];
h1 = Plot[Evaluate[u[x, 1]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 0", LabelStyle Directive[Bold, Blue]];
h2 = Plot[Evaluate[u[x, Pi / 2]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = Pi/2", LabelStyle Directive[Bold, Blue]];
h3 = Plot[Evaluate[u[x, 3]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 3", LabelStyle Directive[Bold, Blue]];
h4 = Plot[Evaluate[u[x, 4]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 4", LabelStyle Directive[Bold, Blue]];
h5 = Plot[Evaluate[u[x, 5]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 5", LabelStyle Directive[Bold, Blue]];
Show[GraphicsGrid[{{h0, h1}, {h2, h3}, {h4, h5}}, Frame All, FrameStyle Black]]
O u t [ ] =
π π
Which- ≤x≤ , Cos[x]3 , True, 0
2 2
O u t [ ] =
Wave at t = 0 Wave at t = 0
1.0 1.0
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-5 0 5 -5 0 5
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-5 0 5 -5 0 5
Wave at t = 4 Wave at t = 5
1.0 1.0
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-5 0 5 -5 0 5
4 PDE Pratical 4.nb
I n [ ] : = c = 1;
f[x_] = Which[- Pi / 2 ≤ x ≤ Pi / 2, Sin[x], True, x ^ 2]
u[x_, t_] := (f[x + c * t] + f[x - c * t]) / 2
h0 = Plot[Evaluate[u[x, 0]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 0", LabelStyle Directive[Bold, Blue]];
h1 = Plot[Evaluate[u[x, 1]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 0", LabelStyle Directive[Bold, Blue]];
h2 = Plot[Evaluate[u[x, Pi / 2]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = Pi/2", LabelStyle Directive[Bold, Blue]];
h3 = Plot[Evaluate[u[x, 3]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 3", LabelStyle Directive[Bold, Blue]];
h4 = Plot[Evaluate[u[x, 4]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 4", LabelStyle Directive[Bold, Blue]];
h5 = Plot[Evaluate[u[x, 5]], {x, - 8, 8}, PlotRange {0, 1},
PlotLabel "Wave at t = 5", LabelStyle Directive[Bold, Blue]];
Show[GraphicsGrid[{{h0, h1}, {h2, h3}, {h4, h5}}, Frame All, FrameStyle Black]]
O u t [ ] =
π π
Which- ≤x≤ , Sin[x], True, x2
2 2
O u t [ ] =
Wave at t = 0 Wave at t = 0
1.0 1.0
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-5 0 5 -5 0 5
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-5 0 5 -5 0 5
Wave at t = 4 Wave at t = 5
1.0 1.0
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-5 0 5 -5 0 5
6 PDE Pratical 4.nb
where vn = v · n is the component of v in the direction of the outer unit normal n of B. Thus, by
Gauss’ theorem (Divergence theorem)
∫ ∫B vn ds = ∫ ∫ ∫D div(-Kgradu) dx dy dz
= -K ∫ ∫ ∫D ∇2 u dx dy dz .
Since the rate of decrease of heat in D must be equal to the amount of heat leaving D per unit
time, we have
-∫ ∫ ∫D σρut dx dy dz = -K ∫ ∫ ∫D ∇2 u dx dy dz
or
-∫ ∫ ∫D [σρut - K∇2 u] dx dy dz = 0
for an arbitrary D in D∗. We assume that the integrand is continuous. If we suppose that the
integrand is not zero at a point (x0, y0, z0) in D, then, by continuity, the integrand is not zero
in a small region surrounding the point (x0, y0, z0). Continuing in this fashion we extend the
region encompassing D. Hence the integral must be nonzero. This contradicts . Thus, the
integrand is zero everywhere, that is,
ut = k ∇2 u,
where κ = K/σρ. This is known as the HEAT EUQATION.
2 pratical 5 pde.nb
PRACTICAL 5
SOLUTION OF HEAT EQUATION utt = kuxx WITH INITIAL CONDITIONS :
Question 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.
I n [ ] : = eqn1a = {∂t u[x, t] - ∂x,x u[x, t] 0, u[x, 0] 0, u[0, t] Sin[t], u[5, t] 0}
O u t [ ] =
I n [ ] : = sol1a = u[x, t] /.
NDSolve[eqn1a, u[x, t], {x, 0, 5}, {t, 0, 10}, PrecisionGoal 3]〚1〛
O u t [ ] =
I n [ ] : = sol1b = u[x, t] /.
NDSolve[eqn1b, u[x, t], {x, 0, 20}, {t, 0, 10}, PrecisionGoal 3]〚1〛
O u t [ ] =
I n [ ] : = sol1c = u[x, t] /.
NDSolve[eqn1c, u[x, t], {x, 0, 20}, {t, 0, 10}, PrecisionGoal 3]〚1〛
O u t [ ] =
I n [ ] : = sol2a = u[x, t] /.
NDSolve[eqn2a, u[x, t], {x, 0, 5}, {t, 0, 10}, PrecisionGoal 3]〚1〛
O u t [ ] =
I n [ ] : = sol2b = u[x, t] /.
NDSolve[eqn2b, u[x, t], {x, 0, 1}, {t, 0, 10}, PrecisionGoal 3]〚1〛
O u t [ ] =
But, from calculus we know that tan α and tan β are the slopes of the string at x and x + δ x :
tan α = ux (x, t)
and
tan β = ux (x + δx , t)
at time t. Equation may thus be written as
1 ρ 1 ρ
= (ux )x + δx - (ux )x ] = utt , = [ux ( x + δx ) - ux (x,t)] = utt
δx T δx T
PRACTICAL 6
Solution of one dimensional wave equation :
Question 1 : (a) utt - uxx = 0, 0 < x < a, t>0,
u(x,0) = Log(1+x^2), 0 < x ⩽ a,
ut (x,0)=2, 0 < x ⩽ a.
I n [ ] : = eqn1a = ∂t,t u[x, t] - ∂x,x u[x, t] 0, u[x, 0] Log1 + x2 ,
Derivative[0, 1][u][x, 0] 2
O u t [ ] =
I n [ ] : = sol1a = u[x, t] /.
NDSolve[eqn1a, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal 3]〚1〛
NDSolve: Warning: an insufficient number of boundary conditions have been specified for the direction of independent
variable x. Artificial boundary effects may be present in the solution.
O u t [ ] =
I n [ ] : = sol1b = u[x, t] /.
NDSolve[eqn1b, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal 3]〚1〛
NDSolve: Warning: an insufficient number of boundary conditions have been specified for the direction of independent
variable x. Artificial boundary effects may be present in the solution.
O u t [ ] =
I n [ ] : = sol2a = u[x, t] /.
NDSolve[eqn2a, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal 3]〚1〛
O u t [ ] =
I n [ ] : = sol2b = u[x, t] /.
NDSolve[eqn2b, u[x, t], {x, 0, 1}, {t, 0, 4}, PrecisionGoal 3]〚1〛
O u t [ ] =
I n [ ] : = sol3a = u[x, t] /.
NDSolve[eqn3a, u[x, t], {x, 0, 1}, {t, 0, 4}]
O u t [ ] =
I n [ ] : = sol3b = u[x, t] /.
NDSolve[eqn3b, u[x, t], {x, 0, 1}, {t, 0, 4}]
O u t [ ] =