Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Partial Differential Equations

Michael Devasia

Solution of Cauchy problem for first order PDE and plot the integral surfaces.
i) 3*u_x + 2*u_y = 0; u(x,0) = sin(x)

In[28]:= ClearAll ;
pde1 = 3 * D[u[x, y], x] + 2 * D[u[x, y], y]
sol1 = DSolve [{pde1 == 0, u[x, 0] == Sin [x]}, u[x, y], {x, y}]

Out[29]= 2 u0,1 [x, y] + 3 u1,0 [x, y]

1
Out[30]=  u[x, y] → Sin  (2 x - 3 y)
2

In[31]:= Plot3D [u[x, y] / . sol1 , {x, - 5, 5}, {y, - 5, 5}]

Out[31]=

ii) x*u_x+y*u_y = 2xy; u=2 on y=x^2


2

In[36]:= ClearAll ;
pde1 = x * D[u[x, y], x] + y * D[u[x, y], y] - 2 * x * y
sol1 = DSolve [{pde1 == 0, u[x, x ^ 2] == 2}, u[x, y], {x, y}]
 0,1   1,0 
Out[37]= -2 x y + y u [x, y] + x u [x, y]

2 x3 + x4 y - y3
Out[38]=  u[x, y] → 
x3

In[39]:= Plot3D [u[x, y] / . sol1 , {x, - 5, 5}, {y, - 5, 5}]

Out[39]=

iii) u_x + x*u_y = y; u(0,y)=y^2

In[40]:= ClearAll ;
pde1 = D[u[x, y], x] + x * D[u[x, y], y] - y
sol1 = DSolve [{pde1 == 0, u[0, y] == y ^ 2}, u[x, y], {x, y}]
 0,1   1,0 
Out[41]= -y + x u [x, y] + u [x, y]

1
 u[x, y] → - 4 x + 3 x + 12 x y - 12 x y + 12 y 
3 4 2 2
Out[42]=
12
3

In[43]:= Plot3D [u[x, y] / . sol1 , {x, - 5, 5}, {y, - 5, 5}]

Out[43]=

iv) u_x + x*u_y = y; u(1,y)=2y

In[44]:= ClearAll ;
pde1 = D[u[x, y], x] + x * D[u[x, y], y] - y
sol1 = DSolve [{pde1 == 0, u[1, y] == 2 * y}, u[x, y], {x, y}]
 0,1   1,0 
Out[45]= -y + x u [x, y] + u [x, y]

1
 u[x, y] → 5 - 3 x - 2 x + 6 y + 6 x y
2 3
Out[46]=
6

In[47]:= Plot3D [u[x, y] / . sol1 , {x, - 5, 5}, {y, - 5, 5}]

Out[47]=
4

2) Plotting the characteristics for first order PDE.


i) x*u_x+y*u_y=u
Characteristic Equation is dx/x=dy/y=du/u
Characteristic Curves are u(x,y)=ax and u(x,y)=by, where a and b are constants

In[11]:= Manipulate [Plot3D [a * x, {x, - 5, 5}, {y, - 5, 5}], {{a, 0.5 }, - 1, 1}]
Manipulate [Plot3D [b * y, {x, - 5, 5}, {y, - 5, 5}], {{b, 0.5 }, - 1, 1}]

Out[11]=
5

Out[12]=

ii) (u-y)*u_x+y*u_y=x+y
Characteristic Equation is dx/(u-y)=dy/y=du/(x+y)
Characteristic Curves are u(x,y)=ay-x and u(x,y)=±sqrt(x^2+2xy+y^2+b), where a and b are constants.

In[13]:= Manipulate [Plot3D [a * y - x, {x, - 5, 5}, {y, - 5, 5}], {{a, 0.5 }, - 1, 1}]
Manipulate [Plot3D [{Sqrt [x ^ 2 + 2 * x * y + y ^ 2 + 2 * b], - Sqrt [x ^ 2 + 2 * x * y + y ^ 2 + 2 * b]},
{ x, - 5, 5} , { y, - 5, 5}], {{ b, 0.5 } , - 1, 1}]
6

Out[13]=
7

Out[14]=

iii) 3*u_x+4*u_y=x
Characteristic Equation is dx/3=dy/4=du/x
Characterisctic Curve is 4x-3y=12a and u(x,y)=(x^2-2b)/6, where a and b are constants.

In[15]:= Manipulate [Plot3D [4 * x - 3 * y = 12 * a, {x, - 5, 5}, {y, - 5, 5}], {{a, 0.5 }, - 1, 1}]
Manipulate [Plot3D [(x ^ 2 + 2 * b) / 6, {x, - 5, 5}, {y, - 5, 5}], {{b, 0.5 }, - 1, 1}]
8

Out[15]=
9

Out[16]=

iv) 4*u_y-x*u_x=1
Characteristic Equation is dx/(-x)=dy/4=du/1
Characteristic Curve is u(x,y)=a-ln(x) and u(x,y)=y/4+b, where a and b are constants.

In[17]:= Manipulate [Plot3D [a - Log [x], {x, 0.1 , 5}, {y, - 5, 5}], {{a, 0.5 }, - 1, 1}]
Manipulate [Plot3D [y / 4 + b, {x, - 5, 5}, {y, - 5, 5}], {{b, 0.5 }, - 1, 1}]
10

Out[17]=
11

Out[18]=

4) Solution of wave equation u_tt = c².u_xx for following conditions:

In[4]:= ClearAll ;
f[x_ ] := Sin [x]; g[x_ ] := Cos [x];

i) u(x,0) = sin(x), u_t(x,0) = cos(x); x∈ℝ, t>0

In[29]:= u[x_ , t_ ] := 1 / 2 * (f[x + c * t] + f[x - c * t]) + 1 / (2 * c) * Integrate [g[y], {y, x - c * t, x + c * t}];


u[x, t] // FullSimplify
Cos [x] Sin [c t]
Out[30]= + Cos [c t] Sin [x]
c

ii) u(x,0) = sin(x), u_t(x,0) = cos(x), u(0,t) = 0; x>0, t>0


12

In[33]:= Clear [u];


u[x_ , t_ ] := Piecewise [
{{ 1 / 2 * (f[x + c * t] + f[x - c * t]) + 1 / (2 * c) * Integrate [g[y], { y, x - c * t, x + c * t}], x > c * t} ,
{ 1 / 2 * (f[x + c * t] - f[c * t - x]) + 1 / (2 * c) * Integrate [g[y], { y, c * t - x, x + c * t}], x < c * t}}];
u[x, t] // FullSimplify
Cos[ x ] Sin[ c t ]
+ Cos [c t] Sin [x] x > ct
c
Out[35]= (1+ c) Cos[ c t ] Sin[ x ]
x < ct
c
0 True

iii) u(x,0) = sin(x), u_t(x,0) = cos(x), u_x(0,t) = 0; x>0, t>0

In[36]:= Clear [u];


u[x_ , t_ ] := Piecewise [
{{ 1 / 2 * (f[x + c * t] + f[x - c * t]) + 1 / (2 * c) * Integrate [g[y], { y, x - c * t, x + c * t}], x > c * t} ,
{ 1 / 2 * (f[x + c * t] + f[c * t - x]) +
1 / (2 * c) * (Integrate [g[y], {y, 0, x + c * t}] + Integrate [g[y], {y, 0, c * t - x}]), x < c * t}}];
u[
x,
t] //
FullSimplify
Cos[ x ] Sin[ c t ]
+ Cos [c t] Sin [x] x > ct
c
Out[38]= (1+ c) Cos[ x ] Sin[ c t ]
x < ct
c
0 True

5) Solution of one dimensional heat equation, u_t = k.u_xx, for a homogeneous rod of length l, i.e, solve
the IBVP u_t = k.u_xx
u(x,0) = f(x), u(0,t) = 0, u(l,t) = 0; 0<x<l, t>0

i) k=4, l=1, f(x)=x^2(1-x)

In[2]:= k = 4; l = 1; f[x_ ] = x ^ 2 * (1 - x);


eqns1 = {D[u[x, t], t] - k * D[u[x, t], {x, 2}] == 0, u[x, 0] == f[x], u[0, t] == 0, u[l, t] == 0};
Sol1 = u[x, t] / . NDSolve [eqns1 , u[x, t], {x, 0, 1}, {t, 0, 4}]

 InterpolatingFunction  [x, t]


Domain : {{0., 1.}, {0., 4.}}
Out[4]=
Output : scalar
13

In[6]:= Plot3D [Sol1 , {x, 0.1 , 1}, {t, 1, 2}, AxesLabel → {"t", "x", ""}]

Out[6]=

ii) k=4, l=π, f(x)=sin(x)^2

In[7]:= k = 4; l = 1; f[x_ ] = Sin [x] ^ 2;


eqns2 = {D[u[x, t], t] - k * D[u[x, t], {x, 2}] == 0, u[x, 0] == f[x], u[0, t] == 0, u[l, t] == 0};
Sol2 = u[x, t] / . NDSolve [eqns2 , u[x, t], {x, 0, 1}, {t, 0, 4}]

NDSolve : Warning : boundary and initial conditions are inconsistent .

 InterpolatingFunction  [x, t]


Domain : {{0., 1.}, {0., 4.}}
Out[9]=
Output : scalar

In[10]:= Plot3D [Sol2 , {x, 0.1 , 1}, {t, 1, 2}, AxesLabel → {"t", "x", ""}]

Out[10]=

iii) k=6, l=2, f(x)=sin(πx)/4


14

In[17]:= k = 6; l = 2; f[x_ ] = Sin [Pi * x] / 4;


eqns3 = {D[u[x, t], t] - k * D[u[x, t], {x, 2}] == 0, u[x, 0] == f[x], u[0, t] == 0, u[l, t] == 1};
Sol3 = u[x, t] / . NDSolve [eqns3 , u[x, t], {x, 0, 1}, {t, 0, 4}]

NDSolve : Warning : boundary and initial conditions are inconsistent .

 InterpolatingFunction  [x, t]


Domain : {{0., 2.}, {0., 4.}}
Out[19]=
Output : scalar

In[20]:= Plot3D [Sol3 , {x, 0.1 , 1}, {t, 1, 2}, AxesLabel → {"t", "x", ""}]

Out[20]=

iv) k=1, l=2, f(x)=x

In[21]:= k = 1; l = 2; f[x_ ] = x;
eqns4 = {D[u[x, t], t] - k * D[u[x, t], {x, 2}] == 0, u[x, 0] == f[x], u[0, t] == 0, u[l, t] == 1};
Sol4 = u[x, t] / . NDSolve [eqns4 , u[x, t], {x, 0, 1}, {t, 0, 4}]

NDSolve : Warning : boundary and initial conditions are inconsistent .

 InterpolatingFunction  [x, t]


Domain : {{0., 2.}, {0., 4.}}
Out[23]=
Output : scalar
15

In[24]:= Plot3D [Sol4 , {x, 0.1 , 1}, {t, 1, 2}, AxesLabel → {"t", "x", ""}]

Out[24]=

6) Solving systems of ordinary differential equations.


i)
dy/dx=3y
dz/dx=2y+3z

In[2]:= sol1 = DSolve [{y '[x] == 3 * y[x], z '[x] == 2 * y[x] + 3 * z[x]}, {y[x], z[x]}, x]
y[x] → ⅇ  1 , z[ x] → 2 ⅇ x  1 + ⅇ 3 x  2 
3x 3x
Out[2]=

In[3]:= Plot [{y[x] / . {sol1 / . C[1] → 1}, z[x] / . sol1 / . {C[1] → 1, C[2] → 4}}, {x, - 5, 5}]
140 000

120 000

100 000

80 000

Out[3]=
60 000

40 000

20 000

-4 -2 2 4

ii)
x''[t]=-5x+2y
y''[t]=-2y+2x
16

In[69]:= sol2 =
DSolve [{x '' [t] == 5 * x[t] + 2 * y[t], y '' [t] == 2 * y[t] + 2 * x[t]}, {x[t], y[t]}, t] // FullSimplify

Out[69]=  x[t] →

1
3 ( 1 - 2  3 ) Cosh [t] + 6 (2  1 +  3 ) Cosh  6 t + 3 ( 2 - 2  4 ) Sinh [t] + 6 (2  2 +  4 ) Sinh  6 t,
15
1
y[ t] → 6 (2  1 +  3 ) Cosh  6 t - 12 (( 1 - 2  3 ) Cosh [t] + ( 2 - 2  4 ) Sinh [t]) +
30
6 (2  2 +  4 ) Sinh  6 t

In[70]:= Plot [{x[t] / . sol2 / . {C[1] → 1, C[2] → 2, C[3] → 3, C[4] → 4},


y[t] / . sol2 / . {C[1] → 1, C[2] → 2, C[3] → 3, C[4] → 4}}, {t, - 5, 5}]

30 000

25 000

20 000

Out[70]=
15 000

10 000

5000

-4 -2 2 4

iii)
x'[t]=-2x+7y
y'[t]=3x+2y x[0]=0,y[0]=1

In[4]:= sol3 = DSolve [{x '[t] == - 2 x[t] + 7 y[t], y '[t] == 3 x[t] + 2 y[t], x[0] == 0, y[0] == 1}, {x[t], y[t]}, t]
7 1
 x[t] → ⅇ - 1 + ⅇ  , y[ t] → ⅇ 3 + 7 ⅇ 
-5 t 10 t -5 t 10 t
Out[4]=
10 10
17

In[5]:= Plot [{x[t] / . sol3 , y[t] / . sol3 }, {t, - 5, 5}]


3 × 10 8

2 × 10 8

1 × 10 8
Out[5]=

-4 -2 2 4

-1 × 10 8

7) Approximate solution to initial value problems using the following approximate methods:
Comparison between exact and approximate results for any representative differential equation.
i) The Euler Method
ii) Modified Euler Method
ii) The Runge-Kutta Method
Euler Method

In[5]:= Euler1 [a0_ , b0_ , n0_ , f _, α_] := Module [{a = a0, b = b0, n = n0, h, ti }, h = (b - a) / n;
ti = Table [a + (j - 1) h, {j, 1, n + 1}];
wi = Table [0, n + 1];
wi [[1]] = α ;
OutputDetails = {{ 0, ti [[1]], α}} ;
For [i = 1, i ≤ n, i ++ , wi [[i + 1]] = wi [[i]] + h * f[ti [[i]], wi [[i]]];
OutputDetails = Append [OutputDetails , { i, N[ti [[i + 1]]], N[wi [[i + 1]]]}];];
Print [
NumberForm [TableForm [OutputDetails , TableHeadings → { None , { "i", "ti", "wi"}}], 6]];
];
18

In[6]:= f[t_ , x_ ] = t / x;
a = 0; b = 5; α = 1; n = 10;
Euler1 [a, b, n, f, α]
i ti wi
0 0 1
1 0.5 1.
2 1. 1.25
3 1.5 1.65
4 2. 2.10455
5 2.5 2.57971
6 3. 3.06426
7 3.5 3.55377
8 4. 4.04621
9 4.5 4.5405
10 5. 5.03604

In[9]:= f[t_ , x_ ] = 1 + x / t;
a = 1; b = 10; α = 2; n = 10;
Euler1 [a, b, n, f, α]
i ti wi
0 1 2
1 1.9 4.7
2 2.8 7.82632
3 3.7 11.2419
4 4.6 14.8764
5 5.5 18.687
6 6.4 22.6449
7 7.3 26.7294
8 8.2 30.9248
9 9.1 35.219
10 10. 39.6021
19

In[12]:= f[t_ , x_ ] = - 2 * x ^ 2 * t;
a = 0; b = 1; α = 1; n = 20;
Euler1 [a, b, n, f, α]
i ti wi
0 0 1
1 0.05 1.
2 0.1 0.995
3 0.15 0.9851
4 0.2 0.970543
5 0.25 0.951704
6 0.3 0.929061
7 0.35 0.903166
8 0.4 0.874616
9 0.45 0.844018
10 0.5 0.811962
11 0.55 0.778998
12 0.6 0.745622
13 0.65 0.712264
14 0.7 0.679289
15 0.75 0.646988
16 0.8 0.615594
17 0.85 0.585277
18 0.9 0.556161
19 0.95 0.528322
20 1. 0.501805

Modified Euler

In[1]:= Euler2 [a0_ , b0_ , n0_ , f _, α_] := Module [{a = a0, b = b0, n = n0, h, ti }, h = (b - a) / n;
ti = Table [a + (j - 1) h, {j, 1, n + 1}];
wi = Table [0, n + 1];
wi [[1]] = α ;
OutputDetails = {{ 0, ti [[1]], α}} ;
For [i = 1, i ≤ n, i ++ ,
wi [[i + 1]] = wi [[i]] + (h / 2) * (f[ti [[i]], wi [[i]]] + f[ti [[i + 1]], wi [[i]] + h * f[ti [[i]], wi [[i]]]]);
OutputDetails = Append [OutputDetails , { i, N[ti [[i + 1]]], N[wi [[i + 1]]]}];];
Print [
NumberForm [TableForm [OutputDetails , TableHeadings → { None , { "i", "ti", "wi"}}], 6]];
];
20

In[6]:= f[t_ , x_ ] = t / x;
a = 0; b = 5; α = 1; n = 10;
Euler2 [a, b, n, f, α]
i ti wi
0 0 1
1 0.5 1.125
2 1. 1.42168
3 1.5 1.80899
4 2. 2.24115
5 2.5 2.69682
6 3. 3.16589
7 3.5 3.6432
8 4. 4.12588
9 4.5 4.61225
10 5. 5.10126

In[121]:= f[t_ , x_ ] = 1 + x / t;
a = 1; b = 10; α = 2; n = 10;
Euler2 [a, b, n, f, α]
i ti wi
0 1 2
1 1.9 4.91316
2 2.8 8.28509
3 3.7 11.9576
4 4.6 15.8543
5 5.5 19.9298
6 6.4 24.1543
7 7.3 28.5065
8 8.2 32.9704
9 9.1 37.5336
10 10. 42.1862

Runge Kutta Method


21

In[34]:= rk [a0_ , b0_ , α 0_ , m0_ , f _] := Module [


{ a = N[a0 ], b = N[b0 ], α = N[α 0 ], m = N[m0 ], k, i} , h = (b - a) / m;
T = Table [0, {i, m + 1}];
Y = Table [0, {i, m + 1}];
T[[1]] = a;
Y[[1]] = α ;
For [k = 1, k ≤ m, k ++ , x0 = T[[k]]; y0 = Y[[k]];
k1 = f[x0, y0 ];
k2 = f[x0 + h / 2, y0 + h * k1 / 2];
k3 = f[x0 + h / 2, y0 + h * k2 / 2];
k4 = f[x0 + h, y0 + h * k3 ];
y[k] = y0 + (h / 6) (k1 + 2 k2 + 2 k3 + k4 );
T[[k + 1]] = a + k * h;
Y[[k + 1]] = y[k];
];
pts = Transpose [{T, Y}];
set1 = Y;
]
22

In[35]:= f[x_ , y _] := Cos [2 x] - Sin [y];


rk [0, 5, 1, 10, f]
plot1 = ListPlot [pts , PlotLegends → {"Approx Solutions "}, PlotStyle → Red ]
sol = NDSolve [{y '[x] == Cos [2 x] - Sin [y[x]], y[0] == 1}, y[x], {x, 0, 5}]
plot2 = Plot [y[x] / . sol , {x, 0, 5}, PlotLegends → {"Exact Solutions "}]
Show [plot2 , plot1 ]

1.0

0.8

0.6

0.4
Out[37]= Approx Solutions
0.2

1 2 3 4 5

-0.2

-0.4

 y[x] → InterpolatingFunction  [x]


Domain : {{0., 5.}}
Out[38]=
Output : scalar

1.0

0.8

0.6

0.4
Out[39]= Exact Solutions
0.2

1 2 3 4 5

-0.2

-0.4

1.0

0.8

0.6

Exact Solutions
0.4
Out[40]=

0.2 Approx Solutions

1 2 3 4 5

-0.2

-0.4
23

In[93]:= f[x_ , y _] := x / y;
rk [0, 5, 1, 10 ]
plot1 = ListPlot [pts , PlotLegends → {"Approx Solutions "}, PlotStyle → Red ]
sol = NDSolve [{y '[x] == x / y[x], y[0] == 1}, y[x], {x, 0, 5}]
plot2 = Plot [y[x] / . sol , {x, 0, 5}, PlotLegends → {"Exact Solutions "}]
Show [plot2 , plot1 ]

Out[95]= Approx Solutions


2

1 2 3 4 5

 y[x] → InterpolatingFunction  [x]


Domain : {{0., 5.}}
Out[96]=
Output : scalar

Out[97]= 3 Exact Solutions

1 2 3 4 5
24

Exact Solutions
Out[98]= 3
Approx Solutions

1 2 3 4 5

In[86]:= Clear [sol , y, f]

In[99]:= f[x_ , y _] := 1 + y / x;
rk [1, 10, 2, 10, f]
plot1 = ListPlot [pts , PlotLegends → {"Approx Solutions "}, PlotStyle → Red ]
sol = NDSolve [{q '[x] == 1 + q[x] / x, q[1] == 2}, q[x], {x, 0, 10 }]
plot2 = Plot [q[x] / . sol , {x, 0, 10 }, PlotLegends → {"Exact Solutions "}]
Show [plot2 , plot1 ]

40

30

Out[101]=
20
Approx Solutions

10

2 4 6 8 10

1
Power : Infinite expression encountered .
0.

NDSolve : The function value {ComplexInfinity } is not a list of numbers with dimensions {1} at {x, q[x]} =
0. , -3.47893 .
-10
× 10

Domain : 7.9 × 10 -1 0 , 10.


Out[102]=  q[x] → InterpolatingFunction  [x]
Output : scalar
25

40

30

Out[103]=
20
Exact Solutions

10

2 4 6 8 10

40

30

Exact Solutions
Out[104]=
20
Approx Solutions

10

2 4 6 8 10

In[111]:= f[x_ , y _] := - 2 y ^ 2 x;
rk [0, 1, 1, 20, f]
plot1 = ListPlot [pts , PlotLegends → {"Approx Solutions "}, PlotStyle → Red ]
sol = NDSolve [{q '[x] == - 2 q[x] ^ 2 x, q[0] == 1}, q[x], {x, 0, 1}]
plot2 = Plot [q[x] / . sol , {x, 0, 1}, PlotLegends → {"Exact Solutions "}]
Show [plot2 , plot1 ]

1.0

0.9

0.8

Out[113]= Approx Solutions


0.7

0.6

0.5

0.2 0.4 0.6 0.8 1.0


26

 q[x] → InterpolatingFunction  [x]


Domain : {{0., 1.}}
Out[114]=
Output : scalar

1.0

0.9

0.8

Out[115]= Exact Solutions


0.7

0.6

0.2 0.4 0.6 0.8 1.0

1.0

0.9

0.8 Exact Solutions


Out[116]=

0.7 Approx Solutions

0.6

0.2 0.4 0.6 0.8 1.0

8) Draw the following sequences of functions on the given interval and discuss pointwise and uniform
convergence
i) x^n
27

In[7]:= f = Table [x ^ n, {n, 1, 10 }];


Plot [f, {x, - 1, 1}, PlotLegends → f]
Manipulate [Plot [x ^ n, {x, - 1, 1}, PlotRange → {- 1, 1}], {n, 1, 10, 1}]

x
1.0
x2

x3

0.5
x4

x5
Out[8]=
x6

-1.0 -0.5 0.5 1.0 x7

x8

x9
-0.5

x 10

1.0

0.5

Out[9]=

-1.0 -0.5 0.5 1.0

-0.5

-1.0

ii) x/n, x∈R


28

In[13]:= F = Table [x / n, {n, 1, 10 }];


Plot [F, {x, - 1, 1}, PlotLegends → F]
Manipulate [Plot [x / n, {x, - 1, 1}, PlotRange → {- 1, 1}], {n, 1, 10, 1}]

x
x
2

x
0.4 3

x
4
0.2
x
5
Out[14]=
x
-1.0 -0.5 0.5 1.0
6

x
-0.2
7

x
-0.4 8

x
9

x
10

1.0

0.5

Out[15]=

-1.0 -0.5 0.5 1.0

-0.5

-1.0

iii) x^2+nx/n x∈R


29

In[16]:= g = Table [(x ^ 2 + n * x) / n, {n, 1, 10 }];


Plot [g, {x, - 10, 10 }, PlotLegends → g]
Manipulate [Plot [(x ^ 2 + n * x) / n, {x, - 10, 10 }, PlotRange → {- 10, 10 }], {n, 1, 10, 1}]

x2 + x

x 2 + 2 x
1
2
50

x 2 + 3 x
1
3
40
x 2 + 4 x
1
4

x 2 + 5 x
30 1
5
Out[17]=
x 2 + 6 x
1
20
6

x 2 + 7 x
1
10 7

x 2 + 8 x
1
8
-10 -5
x 2 + 9 x
5 10 1
9

x 2 + 10 x
1
10

10

Out[18]=

-10 -5 5 10

-5

-10

iv) sin(nx)+n/n
30

In[22]:= G = Table [(Sin [n * x] + n) / n, {n, 1, 10 }];


Plot [G, {x, - 1, 1}, PlotLegends → G]
Manipulate [Plot [(Sin [n * x] + n) / n, {x, - 1, 1}], {n, 1, 10, 1}]

sin(x) + 1
1
(sin(2 x) + 2)
2

1
(sin(3 x) + 3)
3

1.5 1
(sin(4 x) + 4)
4

1
(sin(5 x) + 5)
5
Out[23]= 1.0 1
(sin(6 x) + 6)
6

1
(sin(7 x) + 7)
7
0.5
1
(sin(8 x) + 8)
8

1
-1.0 -0.5 0.5 1.0 (sin(9 x) + 9)
9

1
(sin(10 x) + 10)
10

1.10

1.05

Out[24]=

1.00

0.95

0.90

-1.0 -0.5 0.5 1.0

v) x^n/(x+n)
31

In[43]:= f = Table [x ^ n / (x + n), {n, 1, 10 }];


Plot [f, {x, - 1, 1}, PlotLegends → f]
Manipulate [Plot [x ^ n / (x + n), {x, - 1, 1}, PlotRange → {- 1, 1}], {n, 1, 10, 1}]
x
x+1

x2
x+2

0.20 x3
x+3
0.15
x4
x+4
0.10
x5
x+5
0.05
Out[44]=
x6
x+6
-1.0 -0.5 0.5 1.0
x7
-0.05 x+7

x8
-0.10
x+8

x9
x+9

x 10
x+10

1.0

0.5

Out[45]=

-1.0 -0.5 0.5 1.0

-0.5

-1.0

vi) nx/(1+(nx)^2),x∈R
32

In[46]:= F = Table [n * x / (1 + n ^ 2 * x ^ 2), {n, 1, 10 }];


Plot [F, {x, - 1, 1}, PlotLegends → F]
Manipulate [Plot [n * x / (1 + n ^ 2 * x ^ 2), {x, - 1, 1}], {n, 1, 10, 1}]
x
x 2 +1

2x
4 x 2 +1

3x
0.4 9 x 2 +1

4x

0.2 16 x 2 +1

5x
25 x 2 +1
Out[47]=
-1.0 -0.5 0.5 1.0 6x
36 x 2 +1

-0.2 7x
49 x 2 +1

8x
-0.4
64 x 2 +1

9x
81 x 2 +1

10 x
100 x 2 +1

0.4

0.2
Out[48]=

-1.0 -0.5 0.5 1.0

-0.2

-0.4

vii) nx/(1+nx) x∈R


33

In[49]:= g = Table [n * x / (1 + n * x), {n, 1, 10 }];


Plot [g, {x, - 10, 10 }, PlotLegends → g]
Manipulate [Plot [n * x / (1 + n * x), {x, - 10, 10 }, PlotRange → {- 10, 10 }], {n, 1, 10, 1}]
x
x+1

2x
2 x+1
1.3
3x
3 x+1
1.2
4x
4 x+1
1.1
5x
5 x+1
Out[50]= 1.0
6x
6 x+1
0.9
7x
7 x+1
0.8
8x
8 x+1

-10 -5 5 10 9x
9 x+1

10 x
10 x+1

10

Out[51]=

-10 -5 5 10

-5

-10

viii) x^n/1+x^n
34

In[59]:= g = Table [x ^ n / (1 + x ^ n), {n, 1, 10 }];


Plot [g, {x, - 10, 10 }, PlotLegends → g]
Manipulate [Plot [x ^ n / (1 + x ^ n), {x, - 10, 10 }, PlotRange → {- 10, 10 }], {n, 1, 10, 1}]
x
x+1

x2
x 2 +1
1.2
x3
3
x +1
1.1 x4
4
x +1

1.0 x5
x 5 +1
Out[60]=
x6
0.9 6
x +1

x7

0.8 x 7 +1

x8
x 8 +1
-10 -5 5 10
x9
9
x +1

x 10
x 10 +1

10

Out[61]=

-10 -5 5 10

-5

-10

9. Draw the sequence of unctions and discuss their uniform convergence


i) x^n
35

In[3]:= Manipulate [
Plot [Table [x ^ n, {n, m, 40 }], {x, - 0.9 , 0.9 }, PlotRange → {- 2, 2}, PlotStyle → Red , Epilog →
{ Opacity [0.1 ], LightOrange , EdgeForm [GrayLevel [0.1 ]], Rectangle [{- a, l - ϵ } , { a, l + ϵ }]}],
{ m, 2, 40, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 2

ϵ 0.417

a 0.5

l 0

Out[3]=
1

-0.5 0.5

-1

-2

We can see that, x^n converges uniformly to f(x)=0 in any interval [-a,a] aϵ(0,1)
ii) (x^2+nx)/n
36

In[4]:= Manipulate [Plot [Table [(x ^ 2 + n * x) / n, {n, m, 40 }], {x, - 0.9 , 0.9 },
PlotRange → {- 2, 2}, PlotStyle → Red , Epilog → {Opacity [0.1 ], LightOrange ,
EdgeForm [GrayLevel [0.1 ]], Rotate [Rectangle [{- a, l - ϵ }, {a, l + ϵ }], 45 Degree ]}],
{ m, 2, 40, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 2

ϵ 0.286

a 1.04

l 0

Out[4]=
1

-0.5 0.5

-1

-2

We can see that, (x^2+nx)/n converges uniformly to f(x)=x in [-k,k]; k>0


iii) x/n
37

In[5]:= Manipulate [
Plot [Table [x / n, {n, m, 40 }], {x, - 0.9 , 0.9 }, PlotRange → {- 2, 2}, PlotStyle → Red , Epilog →
{ Opacity [0.1 ], LightOrange , EdgeForm [GrayLevel [0.1 ]], Rectangle [{- a, l - ϵ } , { a, l + ϵ }]}],
{ m, 2, 40, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 2

ϵ 0.273

a 0.56

l 0

Out[5]=
1

-0.5 0.5

-1

-2

We can see that, x/n uniformly converges to f(x)=0, xϵ[-a,a], a>0


iv) x/(x+n)
38

In[1]:= Manipulate [
Plot [Table [x / (x + n), {n, m, 40 }], {x, 0, 1}, PlotRange → {- 2, 2}, PlotStyle → Red , Epilog →
{ Opacity [0.1 ], LightOrange , EdgeForm [GrayLevel [0.1 ]], Rectangle [{- a, l - ϵ } , { a, l + ϵ }]}],
{ m, 2, 40, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 2

ϵ 0.01

a 0

l 0

Out[1]=
1

0.2 0.4 0.6 0.8 1.0

-1

-2

The function x/(x+n) uniformly converges to f(x)=0 on [a,∞], a>0


v) nx/(1+n^2 x^2)
39

In[10]:= Manipulate [Plot [Table [x * n / (1 + (n ^ 2) * x ^ 2), {n, m, 80 }],


{ x, - 0.9 , 0.9 } , PlotRange → {- 2, 2} , PlotStyle → Red , Epilog →
{ Opacity [0.1 ], LightOrange , EdgeForm [GrayLevel [0.1 ]], Rectangle [{- a, l - ϵ } , { a, l + ϵ }]}],
{ m, 2, 80, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 63

ϵ 0.166

a 0.48

l 0

Out[10]=
1

-0.5 0.5

-1

-2

The above function is uniformly convergent to f(x)=0 on [a,∞) , a>0


vi) nx/(1+nx)
40

In[11]:= Manipulate [Plot [Table [x * n / (1 + x * n), {n, m, 40 }],


{ x, - 0.9 , 0.9 } , PlotRange → {- 2, 2} , PlotStyle → Red , Epilog →
{ Opacity [0.1 ], LightOrange , EdgeForm [GrayLevel [0.1 ]], Rectangle [{- a, l - ϵ } , { a, l + ϵ }]}],
{ m, 2, 40, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 34

ϵ 0.195

a 0.41

l 1.

Out[11]=
1

-0.5 0.5

-1

-2

The above function is uniformly convergent to f(x)=1 on [a,∞), a>0


vii) x^n/(1+x^n)
41

In[14]:= Manipulate [Plot [Table [x ^ n / (1 + x ^ n), {n, m, 40 }],


{ x, - 0.9 , 0.9 } , PlotRange → {- 2, 2} , PlotStyle → Red , Epilog →
{ Opacity [0.1 ], LightOrange , EdgeForm [GrayLevel [0.1 ]], Rectangle [{- a, l - ϵ } , { a, l + ϵ }]}],
{ m, 2, 40, 1, Appearance → "Labeled "} , {ϵ , 0.01 , 0.5 , 0.001 , Appearance → "Labeled "} ,
{ a, 0, 2, 0.01 , Appearance → "Labeled "} , { l, 0, 2, 0.01 , Appearance → "Labeled "}]

m 4

ϵ 0.122

a 1.04

l 0

Out[14]=
1

-0.5 0.5

-1

-2

We can see that the function is not uniformly convergent.

You might also like