Maple V for Real Analysis

ICTCM 9 Reno, NV November 2, 1996

Real Analysis with Maple

Alan Arnholt and Bill Bauldry

  arnholt@math.appstate.edu and wmcb@math.appstate.edu

Dept of Mathematical Sciences Appalachian State University

1. Introduction

These worksheets* present a collection of topics from Introductory Real Analysis. The items have been selected to illustrate two views: Maple can be used to gain greater depth when investigating properties; e.g., convergence of sequences and series. Maple can be used in ways which you may find to be quite surprising; e.g., proving theorems, both by induction and symbolic manipulation. Several of the exercises were intended to be quite challenging enjoy your discoveries!

2. The Principal of Mathematical Induction

3. Sequences and Convergence

4. Limits of Functions

5. The Cauchy-Schwarz Inequality

6. Counterexamples in Continuity and Differentiability

7. Power Series and Convergence

*

The worksheets on your disk are for Maple V Release 4. The printed copy was prepared with Maples Export to LaTeX and OzTeX 2.1.

2 The Principal of Mathematical Induction

One of the most powerful techniques of proof is Mathematical Induction.

Theorem. Let P(n) be a statement about the positive integer n such that Basis: P(1) is true Induction: If P(k) is true, then P(k + 1) must also be true.

Then P(n) is true for every positive integer n.

Each Induction proof contains two main sections. The Basis Step is where the statement P(n) is validated for a specific positive integer, typically, but not necessarily, for n=1. The Induction Step is where the conditional If P(k) is true, then P(k+1) must also be true is shown to be valid. The first application of Mathematical Induction considered is usually formulas for sums.

2.1 Summation Formulas

Summation formulas follow the standard template for induction proofs: Esablish the Basis. Algebraically verify the Induction.

Define the proposition.

> P := n -> Sum(k^2, k=1..n) = sum(k^2, k=1..n);

P := n → ∑_{k=1}^{n} k^{2} = ∑_{k=1}^{n} k^{2}

First, the Basis.

> P(1), evalb(value("));

∑_{k=1}^{1} k^{2} = 1, true

Now for the Induction.

> P(n) + ((n+1)^2=(n+1)^2);

(∑_{k=1}^{n} k^{2}) + (n + 1)^{2} = \frac{1}{3} (n + 1)^{3} + \frac{1}{2} (n + 1)^{2} + \frac{1}{6} n + \frac{1}{6}

> factor(");

(∑_{k=1}^{n} k^{2}) + n^{2} + 2 n + 1 = \frac{1}{6} (2 n + 3) (n + 2) (n + 1)

> factor(P(n+1));

∑_{k=1}^{n+1} k^{2} = \frac{1}{6} (2 n + 3) (n + 2) (n + 1)

So the Induction holds. That is, by the PMI,

> factor(P(n));

∑_{k=1}^{n} k^{2} = \frac{1}{6} n (n + 1) (2 n + 1)

is true for all for all positive integers n.

2.2 Binomial Coefficients

Pascal’s Triangle shows many relations between sums and binomial coefficients.

> matrix(10,10, (i,j) -> binomial(i-1,j-1));

Proposition.

> Sum(k, k=1..n-1) = binomial(n,2);

Proposition.

> Sum(k^2, k=1..n-1) = binomial(n,2) + 2*binomial(n,3)

2.3 Additional Activities

Students can be asked to investigate inequalities. E.g.:

> P := n -> 3^n < n!;
> P := n -> 1+n*x < (1+x)^n;

Or, for the adventurous,

> P := n -> 1+sum(a[i],i=1..n)<=product(1+a[i],i=1..n);

3 Sequences and Convergence

3.1 Plotting Sequences

We can often gain insight into a sequences behavior by graphing a selection of terms. The first plot type is to graph n v. a_{n}.

> a := n -> 1+1/(1+a(n-1)); a(1) := 1;

a := n → 1 + \frac{1}{1 + a(n − 1)}

a(1) := 1

> pts := [seq([k,evalf(a(k))],k=1..100)]:  plot(pts, style=point,
symbol=POINT);

> pts := [seq([k,evalf(a(k))], k=20..120)]:  plot(pts, style=point,
symbol=POINT);

The sequence appears to converge rapidly.

> b := n -> sin(n*Pi/2+n)*n/2;

b := n → \frac{1}{2} sin(\frac{1}{2} n π + n) n

> pts := [seq([k,evalf(b(k))], k=1..100)]:  plot(pts, style=point);

> plot(pts);

The second plot type examines apparent accumulation points of a sequence.

> pts := [seq([evalf(a(k)),0],k=1..100)]:  plot(pts, 1.41..1.42,
style=point, symbol=circle, axes=frame);

> pts := [seq([evalf(b(k)),0],k=1..100)]:  plot(pts, style=point,
symbol=circle, axes=frame);

The third approach is to graph the phase-plane of the sequence, a_{n} v. a_{n+1}.

> pts := [seq(evalf([a(k),a(k+1)]),k=1..100)]:  plot(pts, axes=frame);

> pts := [seq(evalf([b(k),b(k+1)]),k=1..100)]:  plot(pts, axes=frame);

3.2 Limits of Sequences and Proofs

What is the limit of a_{n} where

> a := n -> (2*n^2+5/16*n+1/n)/(n^2-17/5*n+1-1/n);

a := n → \frac{2 n^{2} + \frac{5}{16} n + \frac{1}{n}}{n^{2} − \frac{17}{5} n + 1 − \frac{1}{n}}

By inspection, we believe

> Limit(a(n), n=infinity) = 2;

lim_{n→∞} \frac{2 n^{2} + \frac{5}{16} n + \frac{1}{n}}{n^{2} − \frac{17}{5} n + 1 − \frac{1}{n}} = 2

Proof. Let 0 < ε. Then consider

> abs(a(n)-2) < epsilon;

|\frac{2 n^{2} + \frac{5}{16} n + \frac{1}{n}}{n^{2} − \frac{17}{5} n + 1 − \frac{1}{n}} − 2| < ε

> ineq_1 := factor(");

ineq 1 := \frac{1}{16} |\frac{569 n^{2} + 240 − 160 n}{5 n^{3} − 17 n^{2} + 5 n − 5}| < ε

To increase a fraction, increase the numerator.

> y1n := 569*n^2+240-160*n; y2n := 570*n^2;

y1n := 569 n^{2} + 240 − 160 n

y2n := 570 n^{2}

> solve(evalf(y1n<y2n),n);

RealRange(−∞, Open(−161.4861951)), RealRange(Open(1.486195150), ∞) So choose

> n1 := 2:

To increase a fraction, decrease the denominator.

> y1d := 5*n^3-17*n^2+5*n-5; y2d := 5/2*n^3;

y1d := 5 n^{3} − 17 n^{2} + 5 n − 5

y2d := \frac{5}{2} n^{3}

> solve(evalf(y1d>y2d));

RealRange(Open(6.540981457), ∞)

So choose

> n2 := 7:

Thus, for max(n1 , n2 ) < n,

> 1/16*y1n/y1d < 1/16*y2n/y2d;

\frac{1}{16} \frac{569 n^{2} + 240 − 160 n}{5 n^{3} − 17 n^{2} + 5 n − 5} < \frac{57}{4} \frac{1}{n}

We arrive at

> ineq_2 := 1/16*y2n/y2d < epsilon;

ineq 2 := \frac{57}{4} \frac{1}{n} < ε

> ineq_2*n/epsilon;

\frac{57}{4} \frac{1}{ε} < n

Whence, we choose N to be

> N := max(57/4/epsilon, n1, n2);

N := max(7, \frac{57}{4} \frac{1}{ε})

The limit is established.

3.3 Additional Activities

Students can be asked to investigate:

> _seed := 123456789:
> student’s social security number params := expons=rand(-3..3), coeffs=rand(-9..9):
randpoly(n, params):  num := sort("):  randpoly(n, params):  den := sort("):
a := unapply(num/den, n);

Exercises like these give a sense of ownership to students.

4 Limits of Functions

4.1 Limit of a Function at a Point

Find the limit

> f := x -> 1/(sqrt(x^3+1));

f := x → \frac{1}{\sqrt{x^{3} + 1}}

> a := 1:  L := value(subs(x=a, f(x))):  Limit(f(x), x=a) = L;

lim_{x→1} \frac{1}{\sqrt{x^{3} + 1}} = \frac{1}{2} \sqrt{2}

> plot({L,f(x)}, x=0..2);

> Digits := 4:  X1 := evalf([`x`,seq(a-(10-i)/100, i=1..9)]):  X2
:= evalf([`x`,seq(a+(10-i)/100, i=1..9)]):  Y1 := map(f,X1):  Y2
:= map(f,X2):  linalg[augment](X1,Y1,X2,Y2); Digits := 10:

[ \begin{matrix}x & \frac{1}{\sqrt{x^{3} + 1}} & x & \frac{1}{\sqrt{x^{3} + 1}} \\ .9100 & .7553 & 1.090 & .6601 \\ .9200 & .7496 & 1.080 & .6653 \\ .9300 & .7446 & 1.070 & .6702 \\ .9400 & .7391 & 1.060 & .6757 \\ .9500 & .7337 & 1.050 & .6807 \\ .9600 & .7283 & 1.040 & .6859 \\ .9700 & .7231 & 1.030 & .6911 \\ .9800 & .7179 & 1.020 & .6964 \\ .9900 & .7123 & 1.010 & .7018 \end{matrix} ]

Algebraic, numeric, and graphic evidence suggests lim_{x→1} f(x) = \frac{\sqrt{2}}{2}.

4.2 “ε − δ” Proofs

Let ε > 0. Then we must show there is a δ > 0, such that, if |x − a| < δ, then |f(x) − L| < ε. So consider

> f(x)-L; expr_1 := normal(");

\frac{1}{\sqrt{x^{3} + 1}} − \frac{1}{2} \sqrt{2}

expr 1 := −\frac{1}{2} \frac{−2 + \sqrt{2} \sqrt{x^{3} + 1}}{\sqrt{x^{3} + 1}}

“Rationalize the numerator.”

> expr_2 := -expand(numer(expr_1)*(2+sqrt(2)*sqrt(x^3+1)))/
> expand(denom(expr_1)*(2+sqrt(2)*sqrt(x^3+1))) ;

expr 2 := −\frac{2 − 2 x^{3}}{4 \sqrt{x^{3} + 1} + 2 \sqrt{2} x^{3} + 2 \sqrt{2}}

> expr_3 := factor(numer(expr_2))/denom(expr_2);

expr 3 := \frac{(x − 1) (x^{2} + x + 1)}{2 \sqrt{x^{3} + 1} + \sqrt{2} x^{3} + \sqrt{2}}

Substitute δ for x − 1.

> expr_4 := subs(x-1=delta, expr_3);

expr 4 := \frac{δ (x^{2} + x + 1)}{2 \sqrt{x^{3} + 1} + \sqrt{2} x^{3} + \sqrt{2}}

Assume that δ < 1. Then, for |x − 1| < δ, it follows that 0 < x and x < 2. Thence,

> expr_4 < subs(x=2,numer(expr_4))/subs(x=0,denom(expr_4));

\frac{δ (x^{2} + x + 1)}{2 \sqrt{x^{3} + 1} + \sqrt{2} x^{3} + \sqrt{2}} < 7 \frac{δ}{2 + \sqrt{2}}

So that

> ineq_1 := abs(f(x)-L) < 7*delta/(2+2^(1/2));

ineq 1 := |\frac{1}{\sqrt{x^{3} + 1}} − \frac{1}{2} \sqrt{2}| < 7 \frac{δ}{2 + \sqrt{2}}

> ineq_2 := rhs(ineq_1) < epsilon;

ineq 2 := 7 \frac{δ}{2 + \sqrt{2}} < ε

> delta < rhs(ineq_2)*(2+sqrt(2))/7;

δ < \frac{1}{7} ε (2 + \sqrt{2})

Choosing

> delta < min(rhs("),1);

δ < min(1, \frac{1}{7} ε (2 + \sqrt{2}))

and |x − 1| < δ guarantees that |f(x) − L| < ε establishing

> Limit(f(x),x=a) = L;

lim_{x→1} \frac{1}{\sqrt{x^{3} + 1}} = \frac{1}{2} \sqrt{2}

4.3 Additional Activities

Limits of piecewise defined functions can be interesting.

> f := x -> piecewise(x<1,a*x^2,3-x^3); 'f(x)' = f(x);
> f := x -> piecewise(x<1,x+2,x<2,2-x,1-x^2);
> 'f(x)' = f(x);
> plot(f(x),x=0..5, discont=true);
> f := x -> piecewise(x<>0, sin(x)/x,1):  'f(x)' = f(x);
> f := x -> piecewise(x<>0, cos(x)/x,a):  'f(x)' = f(x);

5 The Cauchy-Schwarz Inequality

5.1 The Cauchy-Bunyakovski-Schwarz Inequality

5.1.1 Theorem Let a_{k} and b_{k} be complex numbers for k = 1..n. Then

∑_{k=1}^{n} |a_{k} b_{k}| ≤ \sqrt{(∑_{k=1}^{n} a_{k}^{2}) (∑_{k=1}^{n} b_{k}^{2})} .

5.1.2 Proof

> restart:  with(student):

A sum of squares must be nonnegative, hence

> Sum((abs(a[k])*x+abs(b[k]))^2,k=1..n) >= 0;

0 ≤ ∑_{k=1}^{n} (|a_{k}| x + |b_{k}|)^{2}

Expand the sums and collect like terms in x to find

> expand(");

0 ≤ x^{2} (∑_{k=1}^{n} |a_{k}|^{2}) + 2 x (∑_{k=1}^{n} |a_{k}| |b_{k}|) + (∑_{k=1}^{n} |b_{k}|^{2})

which is a quadratic equation.

> subs( Sum(abs(a[k])^2,k=1..n) = A,
> Sum(abs(a[k])*abs(b[k]),k=1..n) = B
> Sum(abs(b[k])^2,k=1..n) = C, ");

0 ≤ x^{2} A + 2 x B + C

The minimum must occur at the vertex x = −\frac{B}{A} . Substitute and rearrange the inequality, isolating B^{2}.

> subs(x=-B/A, "); expand("*A) + (B^2=B^2);

0 ≤ −\frac{B^{2}}{A} + C

B^{2} ≤ A C Replacing A, B, and C with their respective sums finishes the derivation.

> subs(A=Sum(abs(a[k])^2,k=1 ..n), B=Sum(abs(a[k])*abs(b[k]),k=1..n),
C=Sum(abs(b[k])^2,k=1..n), ");

(∑_{k=1}^{n} |a_{k}| |b_{k}|)^{2} ≤ (∑_{k=1}^{n} |a_{k}|^{2}) (∑_{k=1}^{n} |b_{k}|^{2})

5.2 Additional Activities

The Useful Inequality

> 1/p + 1/q = 1; a*b <= a^p*t^p/p + b^q*t^(-q)/q;

\frac{1}{p} + \frac{1}{q} = 1

a b ≤ \frac{a^{p} t^{p}}{p} + \frac{b^{q} t^{(−q)}}{q}

Holders Inequality

> Sum(a[k]*b[k],k=1..n) <=
> (Sum(a[k]^p,k=1..n))^(1/p)
> * (Sum(b[k]^q,k=1..n))^(1/q);

∑_{k=1}^{n} a_{k} b_{k} ≤ (∑_{k=1}^{n} a_{k}^{p})^{( \frac{1}{p})} (∑_{k=1}^{n} b_{k}^{q})^{( \frac{1}{q})}

Minkowskis Inequality

> (Sum((a[k]+b[k])^p,k=1..n))^(1/p) <= (Sum(a[k]^p,k=1..n))^(1/p)
+(Sum(b[k]^p,k=1..n))^(1/p);

(∑_{k=1}^{n} (a_{k} + b_{k})^{p})^{( \frac{1}{p})} ≤ (∑_{k=1}^{n} a_{k}^{p})^{( \frac{1}{p})} + (∑_{k=1}^{n} b_{k}^{p})^{( \frac{1}{p})}

6 Counterexamples in Continuity and Differentiability

6.1 Continuity and Dirichlets Function

Define Dirichlet’s function

D(x) = \{ \begin{matrix}\frac{1}{q} & x ε Q and x = \frac{p}{q} \\ 0 & otherwise \end{matrix}

where rational x are given in lowest terms. We can implement a Dirichlet function for graphing in Maple with the following procedure:

> pts := proc(n:posint) local i, j, pt_list:
>  pt_list := [0,0]:
>  for i from 1 to n do
>  for j from 1 to i-1 do
>  if gcd(j,i)=1 then
>  pt_list:=pt_list,[j/i, 1/i]; fi;
>  od;
>  od:
>  RETURN([pt_list]):
>  end:

The function returns a list of all points with denominator n. Plot the function (note the timing).

> time():
> the_points := pts(50):
> time() - ""; # 2 sec's (PowerMac 8500/132)
> nops(the_points); # number of points

5.000

774

> time():
> D_plot := plot(evalf(the_points), 0..1, 0..0.5, style=point,
scaling=constrained):
> D_plot;
> time() - """; # 2 sec's (PM 8500/132)

4.000

   > epsilon := 0.05:  plots[display]( [plot(epsilon, x=0..1, 0..0.5,
   color=black), D_plot]);

There are a finite number of points above y = ε. Then f(x) is continuous at the irrational points.

6.2 Differentiability and Weierstrasss Function

K Weierstrass gave the first example of an everywhere continuous, nowhere differentiable function. Choose b to be an odd integer and 0 < a < 1 with ab < 1 + \frac{3}{2} π. Then set

f(x) = ∑_{n=0}^{∞} a^{n} cos(b^{n} π x)

In the interest of time, well not sum to infinity for graphing purposes.

> restart:
> f := (N,x)-> sum(a^n*cos(b^n*Pi*x), n=1..N);

f := (N, x) → ∑_{n=1}^{N} a^{n} cos(b^{n} π x)

> a := 1./2:  b := 13.:  #Note decimals
> plot(f(2,x), x=0..1);

6.3 Additional Activities

Investigate changing values of a and b in Weierstrasss function.

> a := 1./2:  b := 3.:
> plot(f(2,x), x=0..1);

Investigate f(x), over [−1, 1], when

f(x) = \{ \begin{matrix}x^{2} & x ε Q \\ 0 & otherwise \end{matrix}

Code for Dirichlet’s Function:

> Dirichlet := proc(x) local r;
>  if not type(x, {numeric, constant}) then
>  RETURN('Dirichlet'(x)); fi;
>  if x=0 or type(x,string) then
>  RETURN(0) fi;
>  r := convert(x, rational);
>  if type(r,rational) then
>  1/denom(r);
>  else
>  0 fi;
>  end:

7 Power Series and Convergence

7.1 Power Series

A power series is a series of the form

f(x) = a_{0} + (∑_{k=1}^{∞} a_{k} x^{k})

(In Maple, its best to avoid x^{0}.)

7.2 Ratio Test

The ratio test is easy to implement.

> a := n -> n!*(2*n)!/(3*n)!;

a := n → \frac{n! (2 n)!}{(3 n)!}

> r := a(n+1)*x^(n+1)/(a(n)*x^n);

r := \frac{(n + 1)! (2 n + 2)! x^{(n+1)} (3 n)!}{(3 n + 3)! n! (2 n)! x^{n}}

> rho := limit(r, n=infinity);

ρ := \frac{4}{27} x

> solve(abs(rho)<1, x);

RealRange(Open(\frac{−27}{4}), Open(\frac{27}{4}))

Since the ratio is less than 1, the power series converges for |x| < 1. Does it converge to a well-known function?

> 1+sum(a(n)*x^n, n=1..infinity);

1 + \frac{1}{3} x hypergeom([2, 1, \frac{3}{2}], [\frac{5}{3}, \frac{4}{3}], \frac{4}{27} x)

Yes and no!

7.3 Root Test

The root test is just as easy to implement.

> rt := a(n)^(1/n);

rt := (\frac{n! (2 n)!}{(3 n)!})^{( \frac{1}{n})}

> rho := limit(rt*x, n=infinity);

ρ := \frac{4}{27} x

And the rest is the same.

7.4 Limit Comparison Test

One of the most useful tests is the Limit Comparison test. Let

> a := n -> (sin(n)+n)/(2*n^2+n+1);

a := n → \frac{sin(n) + n}{2 n^{2} + n + 1}

Since ∑_{n=1}^{∞} \frac{1}{n} diverges and

> limit(a(n)/(1/n), n=infinity);

\frac{1}{2}

Then ∑ a_{n} diverges. On the other hand,

> b := n -> (2+n)/(2*n^3+n+1);

b := n → \frac{2 + n}{2 n^{3} + n + 1}

> limit(b(n)/(1/n^2), n=infinity);

\frac{1}{2}

shows that ∑ b_{n} converges.

7.5 Integral Test

The Integral test quickly becomes a students favorite with Maple.

> c := n -> sin(n)/n;

c := n → \frac{sin(n)}{n}

> sum(c(n), n=1..infinity);

∑_{n=1}^{∞} \frac{sin(n)}{n}

What do you think?

> evalf(Int(c(x),x=1..infinity));

7.6 Fourier Series

The Fourier Series of a function f(x) is given by

F(x) = \frac{a_{0}}{2} + (∑_{k=1}^{∞} (a_{k} cos(k x) + b_{k} sin(k x)))

where

a_{k} = \frac{1}{π} ∫_{−π}^{π} cos(k t) f(t) dt and b_{k} = \frac{1}{π} ∫_{−π}^{π} sin(k t) f(t) dt

What is the Fourier series of the Heaviside function?

> a := (f,k) -> int(cos(k*t)*f(t),t=-Pi..Pi)/Pi;
> b := (f,k) -> int(sin(k*t)*f(t),t=-Pi..Pi)/Pi;

a := (f, k) → \frac{∫_{−π}^{π}cos(k t) f(t) dt}{π}

b := (f, k) → \frac{∫_{−π}^{π}sin(k t) f(t) dt}{π}

> U := Heaviside:  a(U,k); normal(b(U,k));

\frac{sin(π k)}{k π}

−\frac{cos(π k) − 1}{k π}

> F := (N,x) -> a(U,0)/2 + sum(a(U,k)*cos(k*x)+b(U,k)*sin(k*x),
k=1..N);

F := (N, x) → \frac{1}{2} a(U, 0) + (∑_{k=1}^{N} (a(U, k) cos(k x) + b(U, k) sin(k x)))

>{F(3,x),F(5,x),F(10,x)};

\{\frac{1}{2} + 2 \frac{sin(x)}{π} + \frac{2}{3} \frac{sin(3 x)}{π} + \frac{2}{5} \frac{sin(5 x)}{π}, \frac{1}{2} + 2 \frac{sin(x)}{π} + \frac{2}{3} \frac{sin(3 x)}{π},

\frac{1}{2} + 2 \frac{sin(x)}{π} + \frac{2}{3} \frac{sin(3 x)}{π} + \frac{2}{5} \frac{sin(5 x)}{π} + \frac{2}{7} \frac{sin(7 x)}{π} + \frac{2}{9} \frac{sin(9 x)}{π}\}

> plot({U(x)} union ", x=-Pi..Pi);

Anyone for Gibbs phenomenon?

7.7 Additional Activities

Examine the following series:

S(x) = ∑_{n=2}^{∞} \frac{sin(n x)}{ln(n)}

> b := n -> sin(n*x)/ln(n);

Plot partial sums ...

> S := (N,x) -> sum(b(n), n=2..N);
> plots[animate](S(2*k,x), x=0..10, k=1..5);
> plots[display]([seq(plot(S(2*k,x),x=0..10), k=1..9)], insequence=true);

The ratio test:

> r := b(n+1)/b(n); rho := limit(r, n=infinity); solve(abs(rho)<1,
x);

The root test:

> r := b(n)^(1/n); rho := limit(r, n=infinity); solve(abs(rho)<1,
x);
> plot(S(150,x),x=0..10);

Whats the problem?