%% Created by Maple V Release 4 (APPLE_PPC_MAC)
%% Source Worksheet: Counterexamples.mws
%% Generated: Sat Nov  2 10:45:27 1996
%\documentclass{article}
%\usepackage{maple2e}
%\DefineParaStyle{Heading 1}
%\DefineParaStyle{Heading 2}
%\DefineParaStyle{Maple Output}
%\DefineParaStyle{Maple Plot}
%\DefineParaStyle{Title}
%\DefineCharStyle{2D Comment}
%\DefineCharStyle{2D Math}
%\DefineCharStyle{2D Output}
%\DefineCharStyle{Hyperlink}
%\begin{document}

\begin{maplegroup}
\begin{Title}
\QTR{Hyperlink}{Real Analysis with Maple}
\end{Title}

\end{maplegroup}

\setcounter{section}{5}
\section{Counterexamples in Continuity and Differentiability}

\subsection{Continuity and Dirichlet�s Function}

Define Dirichlet's function

\begin{center}
 
\mapleinline{inert}{2d}{`D(x)` = PIECEWISE([1 `/` q, `x` epsilon `Q
and` x = p / q],[0, otherwise])}{%
${\it D(x)}=\cases{\frac{1}{q} & $x\,\varepsilon \,{\it Q\ and}\,x=
\frac {p}{q}$\cr \ &$\ $\cr 0&${\it otherwise}$\cr }$%
} 
\end{center}

where rational 
\mapleinline{inert}{2d}{x}{%
$x$%
} are given in lowest terms. We can implement a Dirichlet function for
graphing in Maple with the following procedure:

\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{pts := proc(n:posint) local i, j, pt_list:}{}
\mapleinline{active}{1d}{\qquad pt_list := [0,0]:}{}
\mapleinline{active}{1d}{\qquad for i from 1 to n do}{}
\mapleinline{active}{1d}{\qquad\qquad for j from 1 to i-1 do}{}
\mapleinline{active}{1d}{\qquad\qquad\qquad if gcd(j,i)=1 then}{}
\mapleinline{active}{1d}{\qquad\qquad\qquad pt_list:=pt_list,[j/i, 1/i]; fi;}{}
\mapleinline{active}{1d}{\qquad\qquad od;}{}
\mapleinline{active}{1d}{\qquad od:}{}
\mapleinline{active}{1d}{\qquad RETURN([pt_list]):}{}
\mapleinline{active}{1d}{\qquad end:}{}
\end{mapleinput}

\end{maplegroup}
The function returns a list of all points with denominator � 
\mapleinline{inert}{2d}{n}{%
$n$%
}.

Plot the function (note the timing).

\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{time():}{}
\mapleinline{active}{1d}{the_points := pts(50):}{}
\mapleinline{active}{1d}{time() - "";  # 2 sec's (PowerMac 8500/132)}{}
\mapleinline{active}{1d}{nops(the_points); # number of points}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\[
5.000
\]
\end{maplelatex}

\begin{maplelatex}
\[
774
\]
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{time():}{}
\mapleinline{active}{1d}{D_plot := plot(evalf(the_points), 0..1, 0..0.5, style=point,
scaling=constrained):}{}
\mapleinline{active}{1d}{D_plot;}{}
\mapleinline{active}{1d}{time() - """;  # 2 sec's (PM 8500/132)}{%
}
\end{mapleinput}

\mapleresult
\begin{center}
\mapleplot{6_Coun01.eps}
\end{center}

\begin{maplelatex}
\[
4.000
\]
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{epsilon := 0.05:
plots[display](
[plot(epsilon, x=0..1, 0..0.5, color=black), D_plot]);}{%
}
\end{mapleinput}

\mapleresult
\begin{center}
\mapleplot{6_Coun02.eps}
\end{center}

\end{maplegroup}
There are a finite number of points above 
\mapleinline{inert}{2d}{y=epsilon}{%
$y=\varepsilon $%
}. Then 
\mapleinline{inert}{2d}{f(x)}{%
${\rm f}(x)$%
} is continuous at the irrational points.

\subsection{Differentiability and Weierstrass�s Function}

K Weierstrass gave the first example of an everywhere continuous,
nowhere differentiable function. Choose 
\mapleinline{inert}{2d}{b}{%
$b$%
} to be an odd integer and 
\mapleinline{inert}{2d}{0<a}{%
$0 < a$%
} \TEXTsymbol{<} 1 with 
\mapleinline{inert}{2d}{ab<1+(3/2)}{%
${\it ab} < 1 + \frac {3}{2}$%
} 
\mapleinline{inert}{2d}{Pi}{%
$\pi $%
}. Then set

\begin{center}
 
\mapleinline{inert}{2d}{f(x)=Sum(a^n*cos(b^n*Pi*x),n=0..infinity)}{%
${\rm f}(x)=\sum _{n=0}^{\infty }\,a^{n}\,{\rm cos}(b^{n}\,\pi \,
x)$%
} 
\end{center}

In the interest of time, we�ll not sum to infinity for graphing
purposes.

\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{restart:}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{f := (N,x)-> sum(a^n*cos(b^n*Pi*x),
n=1..N);}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\[
f := (N, \,x)\rightarrow {\displaystyle \sum _{n=1}^{N}} \,a^{n}
\,{\rm cos}(b^{n}\,\pi \,x)
\]
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{a := 1./2:  b := 13.:  #Note decimals}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{plot(f(2,x), x=0..1);}{%
}
\end{mapleinput}

\mapleresult
\begin{center}
\mapleplot{6_Coun03.eps}
\end{center}

\end{maplegroup}

\subsection{Additional Activities}

Investigate changing values of 
\mapleinline{inert}{2d}{a}{%
$a$%
} and 
\mapleinline{inert}{2d}{b}{%
$b$%
} in Weierstrass�s function.

\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{a := 1./2:  b := 3.:}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{plot(f(2,x), x=0..1);}{%
}
\end{mapleinput}

\mapleresult
\begin{center}
\mapleplot{6_Coun04.eps}
\end{center}

\end{maplegroup}
Investigate 
\mapleinline{inert}{2d}{f(x)}{%
${\rm f}(x)$%
}, over 
\mapleinline{inert}{2d}{[-1,1]}{%
$[ - 1, \,1]$%
}, when

\begin{center}
 
\mapleinline{inert}{2d}{f(x)=PIECEWISE([x^2, x epsilon Q], [` `,` `],
[0, otherwise])}{%
${\rm f}(x)=\cases{x^{2}&$x\,\varepsilon \,Q$\cr \ &$\ $\cr 0&$
{\it otherwise}$\cr }$%
}  
\end{center}

Code for Dirichlet's Function:

\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{Dirichlet := proc(x) local r;}{}
\mapleinline{active}{1d}{\qquad if not type(x, \{numeric, constant\}) then}{}
\mapleinline{active}{1d}{\qquad \qquad RETURN('Dirichlet'(x)); fi;}{}
\mapleinline{active}{1d}{\qquad if x=0 or type(x,string) then}{}
\mapleinline{active}{1d}{\qquad \qquad RETURN(0) fi;}{}
\mapleinline{active}{1d}{\qquad r := convert(x, rational);}{}
\mapleinline{active}{1d}{\qquad if type(r,rational) then}{}
\mapleinline{active}{1d}{\qquad \qquad 1/denom(r);}{}
\mapleinline{active}{1d}{\qquad else}{}
\mapleinline{active}{1d}{\qquad \qquad 0 fi;}{}
\mapleinline{active}{1d}{\qquad end:}{%
}
\end{mapleinput}

\end{maplegroup}

%\end{document}
%% End of Maple V Output
