Solutions to First and Second Order PDEs
Solutions to First and Second Order PDEs
Q1. Find the general solution of the following first order PDE : ux + uy = 0.
{{u[x, y] 1 [- x + y]}}
1 [- x + y]
I n [ ] : = f[x, 0]
O u t [ ] =
1 [- x]
Q2. Find the general solution of the following first order PDE : x ux + y uy = u .
I n [ ] : = Sol = DSolve[{D[u[x, y], x] + D[u[x, y], y] 0, u[0, y] Sin[y]}, u[x, y], {x, y}]
O u t [ ] =
Q4. Plot the solution of the following first order PDE : x ux + y uy = x e-u , , u (x, y)
= 0 on y = x 2.
I n [ ] : = Pde = D[u[x, y], {x, 2}] - 2 D[u[x, y], x, y] + D[u[x, y], {y, 2}] 0
O u t [ ] =
{{u[x, y] 1 [x + y] + x 2 [x + y]}}
Q6. Find solution of the following Second order PDE : uxx+ 2 uxy - 3 uyy = 0, u[x,
0] = Sin x, uy [x, 0] = x .
I n [ ] : = Pde = D[u[x, y], {x, 2}] + 2 D[u[x, y], x, y] - 3 D[u[x, y], {y, 2}] 0
O u t [ ] =
u[x, y] x2 - y + 2 x y + y2
I n [ ] : = Ch = D[y[x], x] - 1
O u t [ ] =
y′ [x] - 1
{{y[x] - x + 1 }}
-2
-4
-4 -2 0 2 4
Characteristics
6 [Link]
I n [ ] : = Ch = D[y[x], x] 2
O u t [ ] =
y′ [x] 2
{{y[x] 2 x + 1 }}
[Link] 7
10
-5
-4 -2 0 2 4
Characteristics
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
8 [Link]
x - y[x]
I n [ ] : = Ch = D[y[x], x]
x + y[x]
O u t [ ] =
x - y[x]
y′ [x]
x + y[x]
y[x] - x - 2 1 + 2 x2 , y[x] - x + 2 1 + 2 x2
-5
-10
-2 -1 0 1 2
Characteristics
I n [ ] : = Sol = DSolve[{Chsys, x[0] x0, y[0] 0, u[0] f[x0]}, {x[t], y[t], u[t]}, t]
O u t [ ] =
4 -5
-3
3
-1
t
2
1
1 3
0
5
-4 -2 0 2 4
x
10 [Link]
Q 2. Plot the characteristics for the following first order PDE : u ux + uy = 0, u (x,
0) = g (x).
I n [ ] : = Sol = DSolve[{Chsys, x[0] x0, y[0] 0, u[0] g[x0]}, {x[t], y[t], u[t]}, t]
O u t [ ] =
8
-5
6 -3
-1
t
4
1
2
3
5
0
-10 -5 0 5 10
x
I n [ ] : = Sol = DSolve[{Chsys, x[0] x0, y[0] 0, u[0] h[x0]}, {x[t], y[t], u[t]}, t]
O u t [ ] =
6
1
2
t
3
4
4
5
2
0
0 2 4 6 8 10
u
12 [Link]
0.5
0.4
0.3
0.2
0.1
0.0
0 2 4 6 8 10
String at t=2
0.5
x
2 4 6 8 10
-0.5
-1.0
14 [Link]
2.5
2.4
2.3
2.2
2.1
2.0
0 2 4 6 8 10
String at t=2
[Link] 15
Vibrating String at t = 0
u(x,t)
1.0
0.5
x
2 4 6 8 10
-0.5
-1.0
500
400
300
Out[7]=
200
100
0 2 4 6 8 10
String at t=2
Vibrating String at t = 0
u(x,t)
1.0
0.5
Out[8]=
x
2 4 6 8 10
-0.5
-1.0
[Link] 17
Practical 5 :
Solution of heat equation
ut = kuxx with
intitial conditions
The hear equation is :
ut = k uxx, x ∈ (0, L), t > 0
where :
u (x, t) -> temperature at position x and time t, k -> thermal diffusivity constant .
Initial Conditions : u (x, 0) = f (x),
0 < x < L . Boundary conditions
(i) Dirichlet (Fixed Temperature) Conditions
u (0, t) = ϕ1 (t) and u (L, t) = ϕ2 (t)
(ii) Neumann (Insulated/Specified Heat Flux) conditions
ux (0, t) = ψ1 (t) and ux (L, t) = ψ2 (t)
(iii) Robin (Mixed type) conditions
a1 u (0, t) + b1 ux (0, t) = g1 (t), a2 u (L, t) + b2 ux (L, t) = g2 (t)
I n [ ] : = Sol =
DSolve[{Pde, u[x, 0] 0, u[0, t] Sin[t], u[5, t] 0}, u[x, t], {x, t}] /. K[1] n /.
∞5
O u t [ ] =
1
- n 2 π2 t nπx
5 50 25 n2 π2 - 50 n2 π2 Cos[t] - 1250 Sin[t] Sin
1 5
u[x, t] - (- 5 + x) Sin[t] +
5 n=1 625 n π + n5 π5
3125 π + 3125 π5
I n [ ] : = Plot3D[a1[x, t], {x, 0, 5}, {t, 0, 10}, AxesLabel {"x", "t", "u(x,t)]"}]
O u t [ ] =
[Link] 19
I n [ ] : = Sol = DSolvePde, u[x, 0] x2 (1 - x), u[0, t] 0, u[2, t] 0, u[x, t], {x, t} /.
K[1] n /. ∞ 3
O u t [ ] =
2
π2 t nπx
3 8 -n - 2 - 10 (- 1)n + (- 1)n n2 π2 Sin
2
u[x, t]
n=1 n 3 π3
I n [ ] : = g[x_] := 1;
f[x] x ≥ 0 && t 0
∞ ∞ Sin c2 t K[1] ∫0∞ Cos[x K[1]] g[x] x
2 ∫0 Cos[x K[1]] Cos c2 t K[1] ∫0 Cos[x K[1]] f[x] x+ K[1]
c2 K[1]
x ≥ 0 && t > 0
π
Indeterminate True
[Link] 23
c
24 [Link]
I n [ ] : = x0 = -1+Cos[t] x[t];
1
ρ0[x_] = 1 + ;
1 + x2
(*Solution of the problem*)
ρ = ρ0[x0]
O u t [ ] =
1
1+
1 + -2+2 Cos[t] x[t]2
30
25
x0=0.5
20 x0=1
x0=2
15
x0=3
10 x0=4
t
2 4 6 8 10
x[t] - 1 + t + x0
x0 1 - t + x[t]
I n [ ] : = (*Plot of solution*)
Plot3D[Exp[2 t] (1 + Sin[x - Exp[t] + 1] ^ 2),
{x, - 5, 5}, {t, - 2, 2}, AxesLabel {"x", "t", "ρ(x,t)"},
PlotLabel "Traffic density ρ(x,t)", ColorFunction "Mint"]
O u t [ ] =
10
t
-2 -1 1 2
-5