Debian Codegraph @

texmf-dist/doc/latex/pstricks_calcnotes/For_Ps_Output/ThreeAppsPS.tex

raw
1 \documentclass[11pt,a4paper,oneside]{article}
2 \usepackage{calculator}
3 \usepackage{calculus}
4 \usepackage{amsthm}
5 \usepackage{amsmath}
6 \usepackage{cmtt}
7 \usepackage[dvips]{geometry}
8 \usepackage{pstricks}
9 \usepackage{graphicx}
10 \usepackage{graphics}
11 \usepackage{pst-plot}
12 \usepackage{pst-node}
13 \usepackage{multido}
14 \usepackage{pst-xkey}
15 \usepackage{pst-func}
16 \usepackage{pstricks-add}
17 \usepackage[dvips,colorlinks,linktocpage]{hyperref}
18 \def\hantt{\^e}\def\accentcircflx{\hskip-.3em\raisebox{0.32ex}{\'{}}}
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 \def\RiemannSum#1#2#3#4#5#6#7#8#9{%
21 \psplot[linecolor=blue]{#1}{#2}{#3}
22 \pscustom[linecolor=red]{%
23 \psline{-}(#1,0)(#1,0)
24 \multido{\ni=#5,\ne=#6}{#4}
25 {\psline(*{\ni} {#8})(*{\ne} {#9})}}
26 \multido{\ne=#6,\nc=#7}{#4}
27 {\psdot(*{\nc} {#3})
28 \psline[linestyle=dotted,dotsep=1.5pt](\nc,0)(*{\nc} {#3})
29 \psline[linecolor=red](\ne,0)(*{\ne} {#9})}
30 }
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 \newcount\Fa\newcount\Fct\newcount\tempA
33 \def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
34 \def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa \Factor\fi\global\tempA=\Fct}
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 \newcount\BINOM
37 \newcount\temp
38 \newcount\tmp
39 \def\BINOMIAL#1#2{%
40 \temp=#1\advance\temp by -#2
41 \FACTORIAL{#1}
42 \tmp=\tempA
43 \FACTORIAL{\temp}
44 \temp=\tempA
45 \divide\tmp by \temp
46 \FACTORIAL{#2}
47 \temp=\tempA
48 \divide\tmp by \temp\global\BINOM=\tmp}
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 \newdimen\Xa\newdimen\Yb\newcount\kc
51 \newdimen\BSTemp
52 \def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}\else\relax\fi}
53 \def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa by 1pt\xmult{#2}
54 \BINOMIAL{6}{#1}\global\BSTemp=\BINOM\Yb}
55 \newdimen\Xrf\newdimen\Yrf
56 \newdimen\XBST\newdimen\YBST
57 \def\XBC#1#2#3{%
58 \BERNSTEIN{0}{6}{#2}
59 \Xrf=#1pt
60 \XBST=\decimal\BSTemp\Xrf
61 \BERNSTEIN{1}{5}{#2}
62 \Xrf=#1pt\advance\Xrf by -1.5pt
63 \advance\XBST by \decimal\BSTemp\Xrf
64 \BERNSTEIN{2}{4}{#2}
65 \Xrf=#1pt\advance\Xrf by 2pt
66 \advance\XBST by \decimal\BSTemp\Xrf
67 \BERNSTEIN{3}{3}{#2}
68 \Xrf=#1pt\advance\Xrf by 6pt
69 \advance\XBST by \decimal\BSTemp\Xrf
70 \BERNSTEIN{4}{2}{#2}
71 \Xrf=#1pt\advance\Xrf by 5pt
72 \advance\XBST by \decimal\BSTemp\Xrf
73 \BERNSTEIN{5}{1}{#2}
74 \Xrf=#1pt\advance\Xrf by 1.5pt
75 \advance\XBST by \decimal\BSTemp\Xrf
76 \BERNSTEIN{6}{0}{#2}
77 \Xrf=#1pt
78 \advance\XBST by \decimal\BSTemp\Xrf
79 \global\XBST=#3\XBST}
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 \def\YBC#1#2#3{%
82 \BERNSTEIN{0}{6}{#2}
83 \Yrf=#1pt
84 \YBST=\decimal\BSTemp\Yrf
85 \BERNSTEIN{1}{5}{#2}
86 \Yrf=#1pt\advance\Yrf by 2pt
87 \advance\YBST by \decimal\BSTemp\Yrf
88 \BERNSTEIN{2}{4}{#2}
89 \Yrf=#1pt\advance\Yrf by 5pt
90 \advance\YBST by \decimal\BSTemp\Yrf
91 \BERNSTEIN{3}{3}{#2}
92 \Yrf=#1pt\advance\Yrf by 3pt
93 \advance\YBST by \decimal\BSTemp\Yrf
94 \BERNSTEIN{4}{2}{#2}
95 \Yrf=#1pt\advance\Yrf by -1pt
96 \advance\YBST by \decimal\BSTemp\Yrf
97 \BERNSTEIN{5}{1}{#2}
98 \Yrf=#1pt\advance\Yrf by -2pt
99 \advance\YBST by \decimal\BSTemp\Yrf
100 \BERNSTEIN{6}{0}{#2}
101 \Yrf=#1pt
102 \advance\YBST by \decimal\BSTemp\Yrf
103 \global\YBST=#3\YBST}
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 \def\XBsix#1#2{%
106 (1-t)^6*(#1)*(#2)+6*t*(1-t)^5*(#1-1.5)*(#2)+15*t^2*(1-t)^4*(#1+2)*(#2)+
107 20*t^3*(1-t)^3*(#1+6)*(#2)+15*t^4*(1-t)^2*(#1+5)*(#2)+6*t^5*(1-t)*(#1+1.5)*(#2)+t^6*(#1)*(#2)}
108 \def\YBsix#1#2{%
109 (1-t)^6*(#1)*(#2)+6*t*(1-t)^5*(#1+2)*(#2)+15*t^2*(1-t)^4*(#1+5)*(#2)+
110 20*t^3*(1-t)^3*(#1+3)*(#2)+15*t^4*(1-t)^2*(#1-1)*(#2)+6*t^5*(1-t)*(#1-2)*(#2)+t^6*(#1)*(#2)}
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112 \def\NetDraw#1#2#3#4#5{%
113 \newcount\CellNum
114 \newdimen\XRef
115 \newdimen\YRef
116 \newdimen\Xfact
117 \newdimen\Yfact
118 \newdimen\XMin
119 \newdimen\XMax
120 \newdimen\YMin
121 \newdimen\YMax
122 \newdimen\Xsize
123 \newdimen\Ysize
124 \newdimen\tempx
125 \newdimen\tempy
126 \CellNum=#1
127 \XRef=#2pt
128 \YRef=#3pt
129 \Xfact=#4pt
130 \Yfact=#5pt
131 \XMin=\decimal\Xfact\XRef \advance\XMin by -1.50\Xfact
132 \XMax=\decimal\Xfact\XRef \advance\XMax by 5.00\Xfact
133 \YMin=\decimal\Yfact\YRef \advance\YMin by -6.00\Yfact
134 \YMax=\decimal\Yfact\YRef \advance\YMax by \Yfact
135 \Xsize=\XMax \advance\Xsize by -\XMin \divide\Xsize by \CellNum
136 \Ysize=\YMax \advance\Ysize by -\YMin \divide\Ysize by \CellNum
137 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!30,plotpoints=200,linewidth=0.5pt]{0}{0.5}
138 {\XBeight{\decimal\XRef}{\decimal\Xfact}|\YBeight{\decimal\YRef}{\decimal\Yfact}}
139 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!30,plotpoints=200,linewidth=0.5pt]{0.5}{1}
140 {\XBeight{\decimal\XRef}{\decimal\Xfact}|\YBeight{\decimal\YRef}{\decimal\Yfact}}
141 \multido{\nz=0.00+0.05}{200}{\XBC{\decimal\XRef}{\nz}{\decimal\Xfact}\YBC{\decimal\YRef}{\nz}{\decimal\Yfact}
142 \multido{\nx=\decimal\XMin+\decimal\Xsize}{\the\CellNum}
143 {\tempx=\nx pt\multido{\ny=\decimal\YMin+\decimal\Ysize}{\the\CellNum}
144 {\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize%
145 \ifdim\YBST>\tempy\relax\else
146 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
147 \ifdim\XBST>\tempx\relax\else
148 \pspolygon[fillstyle=solid,fillcolor=red!90,linecolor=black,linewidth=0.2pt]
149 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\relax\fi\fi\fi\fi}
150 }}
151 \advance\CellNum by 1
152 \multido{\nx=\decimal\XMin+\decimal\Xsize}{\the\CellNum}
153 {\psline[linewidth=0.2pt](\nx,\decimal\YMax)(\nx,\decimal\YMin)}
154 \multido{\ny=\decimal\YMin+\decimal\Ysize}{\the\CellNum}
155 {\psline[linewidth=0.2pt](\decimal\XMin,\ny)(\decimal\XMax,\ny)}
156 \parametricplot[algebraic,linecolor=white,plotpoints=200,linewidth=0.5pt]{0}{0.5}
157 {\XBeight{\decimal\XRef}{\decimal\Xfact}|\YBeight{\decimal\YRef}{\decimal\Yfact}}
158 \parametricplot[algebraic,linecolor=white,plotpoints=200,linewidth=0.5pt]{0.5}{1}
159 {\XBeight{\decimal\XRef}{\decimal\Xfact}|\YBeight{\decimal\YRef}{\decimal\Yfact}}
160 }
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 \def\avecfld#1#2#3#4#5#6{%
163 \multido{#2}{#4}
164 {\multido{#1}{#3}
165 {\parametricplot[algebraic,arrows=->,linecolor=red]{0}{1}
166 {\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}}}}
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 \def\anothervecfld#1#2#3#4#5#6{%
169 \multido{#2}{#4}
170 {\multido{#1}{#3}
171 {\curvepnodes[algebraic,plotpoints=2]{0}{1}
172 {\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}{P}
173 \psline[linewidth=0.7pt,linecolor=red]{->}(P0)(P1)}}}
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 \def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
176 \xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 \def\vecfldnew#1#2#3#4#5#6#7#8{%
179 \newcount\intg \newdimen\fx \newdimen\fy \newdimen\slope \newdimen\interm
180 \def\fintg{\interm=#8 \interm=\intg\interm \ifdim\ifdim\slope<0pt-\fi\slope<\interm\advance\intg by -1\relax\else\advance\intg by 1\fintg\fi}
181 \multido{#2}{#4}
182 {\multido{#1}{#3}
183 {\curvepnodes[algebraic,plotpoints=2]{0}{1}{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}{P}
184 #7 \slope=10\slope\fintg
185 \ifnum\intg>10\psline[linecolor=red]{->}(P0)(P1)\else\ifnum\intg=0\psline[linecolor=red!5]{->}(P0)(P1)\else\multiply\intg by 10
186 \psline[linecolor=red!\the\intg]{->}(P0)(P1)\fi\fi
187 \intg=0\slope=0pt
188 }}}
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 \pagestyle{headings}
191 \topmargin=-0.6cm
192 \textwidth=16.7cm
193 \textheight=23cm
194 \headheight=2.5ex
195 \headsep=0.6cm
196 \oddsidemargin=.cm
197 \evensidemargin=-.4cm
198 \parskip=0.7ex plus0.5ex minus 0.5ex
199 \baselineskip=17pt plus2pt minus2pt
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 \catcode`@=11
202 \renewcommand\section{\@startsection {section}{1}{\z@}%
203 {-3.5ex \@plus -1ex \@minus -.2ex}%
204 {2.3ex \@plus.2ex}%
205 {\normalfont\large\bfseries}}
206 \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
207 {-3.25ex\@plus -1ex \@minus -.2ex}%
208 {1.5ex \@plus .2ex}%
209 {\normalfont\normalsize\bfseries}}
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211 \gdef\acknw{\section*{%
212 {\acknwname}\markright{\protect\textsl{\acknwname}}}%
213 \addcontentsline{toc}{section}{\acknwname}}
214 \gdef\acknwname{Acknowledgment}
215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 \renewcommand\sectionmark[1]{\markright{\thesection. #1}}
217 \newcounter{lk}
218 \newenvironment{listof}{\begin{list}{\rm(\roman{lk})}{\usecounter{lk}%
219 \setlength{\topsep}{0ex plus0.1ex}%
220 \setlength{\labelwidth}{1cm}%
221 \setlength{\itemsep}{0ex plus0.1ex}%
222 \setlength{\itemindent}{0.5cm}%
223 }}{\end{list}}
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225 \title{Three applications of macros in \texttt{PSTricks}\thanks{PSTricks is the original work of Timothy Van Zandt (email address: \texttt{[email protected]}).
226 It is currently edited by Herbert Vo\ss\ (\texttt{[email protected]}).}}
227 \author{Le Phuong Quan\\
228 \small{(Cantho University, Vietnam)}\\
229 \small{\texttt{[email protected]}}}
230 \begin{document}
231 \maketitle
232 \tableofcontents
233 \section{Drawing approximations to the area under a graph by rectangles}
234 \subsection{Description}
235
236 We recall here an operation in Calculus. Let $f(x)$ be a function, defined and bounded on
237 an interval $[a,b]$. If $f$ is integrable (in Riemann sense) on $[a,b]$, then its definite integral over this interval
238 is
239 $$\int_a^bf(x)dx=\lim_{\|P\|\to 0}\sum_{i=1}^nf(\xi_i)\Delta x_i,$$
240 where $P\colon a=x_0<x_1<\cdots<x_n=b$, $\Delta x_i=x_i-x_{i-1}$ is a partition of $[a,b]$, $\xi_i\in[x_{i-1},x_i]$, $i=1,2,\ldots,n$,
241 and $\|P\|=\max\{\Delta x_i\colon i=1,2,\ldots,n\}$. Hence, when $\|P\|$ is small enough, we may have an
242 approximation
243 \begin{equation}\label{eqn1}
244 I=\int_a^bf(x)dx\approx\sum_{i=1}^nf(\xi_i)\Delta x_i.
245 \end{equation}
246 Because $I$ is independent to the choice of $P$ and $\xi_i$, we may
247 divide $[a,b]$ into $n$ subintervals with equal length and choose $\xi_i=(x_i+x_{i-1})/2$.
248 Then, $I$ can be approximately seen as the sum of areas of the rectangles with sides
249 $f(\xi_i)$ and $\Delta x_i$.
250
251 We will make a drawing procedure to illustrate the approximation (\ref{eqn1}). Firstly, we establish
252 commands to draw the ``sum'' of rectangles, like the area under piecewise-constant functions
253 (called \textsl{step shape\/}, for brevity). The chosen procedure here
254 obviously includes a combination of the macros \texttt{\symbol{92}pscustom} (to \textsl{join\/} horizontal segments, automatically)
255 and \texttt{\symbol{92}multido}. In particular, horizontal segments are depicted within the loop
256 \texttt{\symbol{92}multido} by
257 $$\textmtt{\symbol{92}psplot[{\it settings}]\{$x_{i-1}$\}\{$x_i$\}\{$f(\xi_i)$\}}$$
258 Then, \texttt{\symbol{92}pscustom} will join these segments altogether with the ending points
259 $(a,0)$, $(b,0)$ to make the boundary of the step shape. Next, we draw the points $(\xi_i,f(\xi_i))$, $i=1,2,\ldots,n$,
260 and the dotted segments between these points and the points $(\xi_i,0)$, $i=1,2,\ldots,n$, by
261 \begin{align*}
262 &\textmtt{\symbol{92}psdot[algebraic,\dots](*\{$\xi_i$\} \{$f(x)$\})}\\
263 &\textmtt{\symbol{92}psline[algebraic,linestyle=dotted,\dots]($\xi_i$,$0$)(*\{$\xi_i$\} \{$f(x)$\})}
264 \end{align*}
265 where we use the structure \textmtt{(*\{{\it value}\} \{$f(x)$\})} to obtain $(\xi_i,f(\xi_i))$. Finally, we draw
266 vertical segments to split the step shape into rectangular cells by
267 $$\textmtt{\symbol{92}psline[algebraic,\dots]($x_i$,$0$)(*\{$x_i$\} \{$f(x-\Delta x_i/2)$\})}$$
268 The process of approximation is depicted in Figure \ref{Fig1}.
269 \begin{figure}[htbp]
270 \centering\begin{pspicture}(-2,-2)(3,3.5)
271 \psset{yunit=0.2}
272 \psaxes[labelFontSize=$\footnotesize$,Dy=2,ticksize=2.2pt,labelsep=4pt]{->}(0,0)(-2.5,-10)(3.5,15.5)
273 \psplot[plotpoints=500,algebraic,linecolor=red]{-2}{3}{x^3-2*x^2+6}
274 \pscustom{
275 \psline{-}(-2,0)(-2,0)
276 \multido{\nx=-2.000+0.500,\ny=-1.750+0.500,\ni=-1.500+0.500}{10}
277 {\psplot[algebraic]{\nx}{\ni}{(\ny)^3-2*(\ny)^2+6}}
278 \psline{-}(3,0)}
279 \end{pspicture}
280 \hskip3em
281 \begin{pspicture}(-2,-2)(3,3.5)
282 \psset{yunit=0.2}
283 \psaxes[labelFontSize=$\footnotesize$,Dy=2,ticksize=2.2pt,labelsep=4pt]{->}(0,0)(-2.5,-10)(3.5,15.5)
284 \psplot[plotpoints=500,algebraic,linecolor=red]{-2}{3}{x^3-2*x^2+6}
285 \pscustom{
286 \psline{-}(-2,0)(-2,0)
287 \multido{\nx=-2.000+0.500,\ny=-1.750+0.500,\ni=-1.500+0.500}{10}
288 {\psplot[algebraic]{\nx}{\ni}{(\ny)^3-2*(\ny)^2+6}}
289 \psline{-}(3,0)}
290 \multido{\nx=-2.000+0.500,\ny=-1.750+0.500,\ni=-1.500+0.500}{10}
291 {\psline[linestyle=dotted,dotsep=1.5pt,dotstyle=o,linecolor=gray](\ny,0)(*{\ny} {x^3-2*x^2+6})
292 \psdot[dotsize=1.2pt 1,dotstyle=Bo](*{\ny} {x^3-2*x^2+6})}
293 \end{pspicture}\\[3ex]
294 \centering\begin{pspicture}(-2,-2)(3,3)
295 \psset{yunit=0.2}
296 \psaxes[labelFontSize=$\footnotesize$,Dy=2,ticksize=2.2pt,labelsep=4pt]{->}(0,0)(-2.5,-10)(3.5,15.5)
297 \psplot[plotpoints=500,algebraic,linecolor=red]{-2}{3}{x^3-2*x^2+6}
298 \pscustom{
299 \psline{-}(-2,0)(-2,0)
300 \multido{\nx=-2.000+0.500,\ny=-1.750+0.500,\ni=-1.500+0.500}{10}
301 {\psplot[algebraic]{\nx}{\ni}{(\ny)^3-2*(\ny)^2+6}}
302 \psline{-}(3,0)}
303 \multido{\nx=-2.000+0.500,\ny=-1.750+0.500,\ni=-1.500+0.500}{10}
304 {\psline[linestyle=dotted,dotsep=1.5pt,dotstyle=o,linecolor=gray](\ny,0)(*{\ny} {x^3-2*x^2+6})
305 \psdot[dotsize=1.2pt 1,dotstyle=Bo](*{\ny} {x^3-2*x^2+6})}
306 \multido{\nx=-2.000+0.500,\ny=-1.750+0.500,\ni=-1.500+0.500}{9}
307 {\psline(\ni,0)(*{\ni} {(x-0.25)^3-2*(x-0.25)^2+6})}
308 \end{pspicture}
309 \caption{Steps to make the drawing procedure.}\label{Fig1}
310 \end{figure}
311
312 We now combine the above steps to make a procedure whose calling sequence consists of main parameters
313 $a$, $b$, $f$ and $n$, and dependent parameters $x_{i-1}$, $x_i$, $\xi_i$, $f(\xi_i)$ and
314 $f(x\pm\Delta x_i/2)$. For instance, let us consider approximations to the integral of $f(x)=\sin x-\cos x$
315 over $[-2,3]$ in cases of $n=5$ and $n=20$. They are given in Figure \ref{Fig2}.
316 \begin{figure}[htbp]
317 \centering\begin{pspicture}(-2.5,-3)(3.5,3.01)
318 \psset{plotpoints=500,algebraic,dotsize=1pt 2,yunit=2}
319 \psaxes[labelFontSize=$\footnotesize$,Dy=1]{->}(0,0)(-2.5,-1.5)(3.5,1.5)
320 \RiemannSum{-2}{3}{sin(x)-cos(x)}{5}
321 {-2.0+1.0}{-1.0+1.0}{-1.5+1.0}
322 {sin(x+0.5)-cos(x+0.5)}{sin(x-0.5)-cos(x-0.5)}
323 \end{pspicture}
324 \hskip4em
325 \begin{pspicture}(-2.5,-3)(3.5,3.01)
326 \psset{plotpoints=500,algebraic,dotsize=1pt 2,yunit=2}
327 \psaxes[labelFontSize=$\footnotesize$,Dy=1]{->}(0,0)(-2.5,-1.5)(3.5,1.5)
328 \RiemannSum{-2}{3}{sin(x)-cos(x)}{20}
329 {-2.000+0.250}{-1.750+0.250}{-1.875+0.250}
330 {sin(x+0.125)-cos(x+0.125)}{sin(x-0.125)-cos(x-0.125)}
331 \end{pspicture}
332 \caption{Approximations to the integral of $f(x)=\sin x-\cos x$ over $[-2,3]$.}\label{Fig2}
333 \end{figure}
334
335 In summary, we can make a procedure to illustrate the approximation (\ref{eqn1}), say \texttt{RiemannSum}, whose calling sequence has the form of
336 $$\textmtt{\symbol{92}RiemannSum\{$a$\}\{$b$\}\{$f(x)$\}\{$n$\}\{$x_{\rm ini}$\}\{$x_{\rm end}$\}\{$x_{\rm choice}$\}\{$f(x+\Delta x_i/2)$\}\{$f(x-\Delta x_i/2)$\}},$$
337 where $x_0=a$ and for each $i=1,2\ldots,n$:
338 \begin{align*}
339 x_i&=a+\dfrac{b-a}{n}i,\quad\Delta x_i=x_i-x_{i-1}=\dfrac{b-a}{n},\\
340 x_{\rm ini}&=x_0+\Delta x_i,\quad x_{\rm end}=x_1+\Delta x_i,\quad x_{\rm choice}=\dfrac{x_{\rm ini}+x_{\rm end}}{2}=\dfrac{x_0+x_1}{2}+\Delta x_i.
341 \end{align*}
342 Note that $x_{\rm ini}$, $x_{\rm end}$ and $x_{\rm choice}$ are given in such forms to be
343 suitable to variable declaration in \texttt{\symbol{92}multido}. They are nothing but
344 $x_{i-1}$, $x_i$ and $\xi_i$, respectively, at the step $i$-th in the loop.
345
346 Tentatively, in \texttt{PSTricks} language, the definition of \texttt{RiemannSum} is suggested to be
347 \bigskip\hrule
348 \noindent\begin{tabular}{@{}l}
349 \verb!\def\RiemannSum#1#2#3#4#5#6#7#8#9{%!\\
350 \verb!\psplot[linecolor=blue]{#1}{#2}{#3}!\\
351 \verb!\pscustom[linecolor=red]{%!\\
352 \verb!\psline{-}(#1,0)(#1,0)!\\
353 \verb!\multido{\ni=#5,\ne=#6}{#4}!\\
354 \verb!{\psline(*{\ni} {#8})(*{\ne} {#9})}}!\\
355 \verb!\multido{\ne=#6,\nc=#7}{#4}!\\
356 \verb!{\psdot(*{\nc} {#3})!\\
357 \verb!\psline[linestyle=dotted,dotsep=1.5pt](\nc,0)(*{\nc} {#3})!\\
358 \verb!\psline[linecolor=red](\ne,0)(*{\ne} {#9})}}!
359 \end{tabular}\hrule
360 \subsection{Examples}
361 We give here two more examples just to see that using the drawing procedure is very easy. In the first example, we approximate
362 the area under the graph of the function $f(x)=x-(x/2)\cos x+2$ on the interval $[0,8]$. To draw the approximation, we try
363 the case $n=16$; thus $x_0=0$ and for each $i=1,\ldots,16$, we have
364 $x_i=0.5\,i$, $\Delta x_i=0.5$, $x_{\rm ini}=0.00+0.50$, $x_{\rm end}=0.50+0.50$ and $x_{\rm choice}=0.25+0.50$.
365 \begin{figure}[htbp]
366 \centering\begin{pspicture}(0,0)(5.1,6.6)
367 \psset{plotpoints=500,algebraic,dotsize=1pt 2,unit=0.6}
368 \RiemannSum{0}{8}{x-(x/2)*cos(x)+2}{16}{0.00+0.50}{0.50+0.50}{0.25+0.50}
369 {x+0.25-((x+0.25)/2)*cos(x+0.25)+2}{x-0.25-((x-0.25)/2)*cos(x-0.25)+2}
370 \psaxes[labelFontSize=$\footnotesize$,Dy=1,ticksize=2.2pt,labelsep=4pt]{->}(0,0)(8.5,11)
371 \end{pspicture}
372 \vskip0.5ex
373 \caption{An approximation to the area under the graph of $f(x)=x-(x/2)\cos x+2$ on $[0,8]$.}\label{Fig3}
374 \end{figure}
375
376 To get Figure \ref{Fig3}, we have used the following \LaTeX\ code:
377 \bigskip\hrule
378 \noindent\begin{tabular}{@{}l}
379 \verb!\begin{pspicture}(0,0)(4.125,5.5)!\\
380 \verb!\psset{plotpoints=500,algebraic,dotsize=2.5pt,unit=0.5}!\\
381 \verb!\RiemannSum{0}{8}{x-(x/2)*cos(x)+2}{16}{0.00+0.50}{0.50+0.50}{0.25+0.50}!\\
382 \verb!{x+0.25-((x+0.25)/2)*cos(x+0.25)+2}{x-0.25-((x-0.25)/2)*cos(x-0.25)+2}!\\
383 \verb!\psaxes[ticksize=2.2pt,labelsep=4pt]{->}(0,0)(8.5,11)!\\
384 \verb!\end{pspicture}!
385 \end{tabular}\hrule\bigskip
386
387 In the second example below, we will draw an approximation to the integral of $f(x)=x\sin x$ over $[1,9]$.
388 Choosing $n=10$ and computing parameters needed, we get Figure \ref{Fig4}, mainly by
389 the command
390 \begin{align*}
391 &\textmtt{\symbol{92}RiemannSum\{$1$\}\{$9$\}\{$x\sin x$\}\{$10$\}\{$1.00+0.80$\}\{$1.80+0.80$\}\{$1.40+0.80$\}}\\
392 &\textmtt{\{$(x+0.4)\sin(x+0.4)$\}\{$(x-0.4)\sin(x-0.4)$\}}
393 \end{align*}
394 in the drawing procedure.
395 \begin{figure}[htbp]
396 \centering\begin{pspicture}(0,-2.5)(4.75,4.25)
397 \psset{plotpoints=500,algebraic,dotsize=1pt 2,unit=0.5}
398 \RiemannSum{1}{9}{x*sin(x)}{10}%
399 {1.00+0.80}{1.80+0.80}{1.40+0.80}%
400 {(x+0.4)*sin(x+0.4)}{(x-0.4)*sin(x-0.4)}
401 \psaxes[labelFontSize=$\footnotesize$,Dy=1,ticksize=2.2pt,labelsep=4pt]{->}(0,0)(0,-5)(9.5,8.5)
402 \end{pspicture}
403 \caption{An approximation to the integral of $f(x)=x\sin x$ over $[1,9]$.}\label{Fig4}
404 \end{figure}
405 \section{Drawing the vector field of an ordinary differential equation of order one}
406 \subsection{Description}\label{sect1}
407
408 Let us consider the differential equation
409 \begin{equation}\label{eqn2}
410 \frac{dy}{dx}=f(x,y).
411 \end{equation}
412 At each point $(x_0,y_0)$ in the domain $D$ of $f$, we will put a vector $\mathbf{v}$ with slope
413 $k=f(x_0,y_0)$. If $y(x_0)=y_0$, then $k$ is the slope of the tangent to the solution curve $y=y(x)$
414 of (\ref{eqn2}) at $(x_0,y_0)$. The $\mathbf{v}$'s make a \textsl{vector field\/} and the picture
415 of this field would give us information about the shape of solution curves of (\ref{eqn2}), even
416 we have not found yet any solution of (\ref{eqn2}).
417
418 The vector field of (\ref{eqn2}) will be depicted on a finite grid of points in $D$. This grid is made of
419 lines, paralell to the axes $Ox$ and $Oy$. The intersectional points of those lines are called \textsl{grid points\/}
420 and often indexed by $(x_i,y_j)$, $i=0,\ldots,N_x$, $j=0,\ldots,N_y$. For convenience, we will use
421 polar coordinates to locate the terminal point $(x,y)$ of a field vector, with the initial point at
422 grid point $(x_i,y_j)$. Then, we can write
423 \begin{align*}
424 x&=x_i+r\cos\varphi,\\
425 y&=y_j+r\sin\varphi.
426 \end{align*}
427 Because $k=f(x_i,y_j)=\tan\varphi$ is finite, we may take $-\pi/2<\varphi<\pi/2$.
428 From $\sin^2\varphi+\cos^2\varphi=1$ and $\sin\varphi=k\cos\varphi$, we derive
429 $$\cos\varphi=\frac{1}{\sqrt{1+k^2}},\quad\sin\varphi=\frac{k}{\sqrt{1+k^2}}.$$
430 \begin{figure}[htbp]
431 \centering\begin{pspicture}(0,0)(5,5)
432 \psset{unit=2}
433 \psaxes[labelFontSize=$\footnotesize$,Dx=0.5,Dy=0.5,labels=none,ticksize=2pt,labelsep=2pt,linewidth=0.5pt]
434 {->}(0,0)(2.5,2.5)
435 \psdots[dotstyle=*,dotsize=3pt,linecolor=red](1,1)(1.5,1)(1,1.5)
436 \psline[linewidth=0.3pt](1.5,0.5)(1.5,2)(1,2)(1,0.5)(2,0.5)(2,1.5)
437 \psline[linewidth=0.3pt](1,1.5)(2,1.5)\psline[linewidth=0.3pt](1,1)(2,1)
438 \psarc[linewidth=0.5pt,linestyle=dotted,dotsep=1.5pt](1,1){0.5}{-90}{90}
439 \psarc[linewidth=0.5pt,linestyle=dotted,dotsep=1.5pt](1.5,1){0.5}{-90}{90}
440 \psarc[linewidth=0.5pt,linestyle=dotted,dotsep=1.5pt](1,1.5){0.5}{-90}{90}
441 \psline[linewidth=0.8pt,linecolor=red]{->}(1,1.5)(1.27,1.92)
442 \psline[linewidth=0.8pt,linecolor=red]{->}(1,1)(1.382,1.322)
443 \psline[linewidth=0.8pt,linecolor=red]{->}(1.5,1)(1.977,1.147)
444 \rput(1,-0.1){$x_i$}\rput(1.5,-0.1){$x_{i+1}$}\rput(-0.1,1){$y_j$}\rput(-0.2,1.5){$y_{j+1}$}
445 \end{pspicture}
446 \caption{Field vectors on a grid.}\label{Fig5}
447 \end{figure}
448 The field vectors should all have the same magnitude and we choose here that length to be
449 $1/2$, that means $r=1/2$. Thus, vectors on the grid have their initial and terminal points as
450 $$(x_i,y_j),\quad \Big(x_i+\frac{1}{2}\cos\varphi,y_j+\frac{1}{2}\sin\varphi\Big),$$
451 respectively. Hence, we easily get the parametrization of a vector at grid point
452 $(x_i,y_j)$:
453 \begin{align*}
454 x&=x_i+\frac{t}{2}\cos\varphi=x_i+\frac{t}{2\sqrt{1+k^2}},\\
455 y&=y_j+\frac{t}{2}\sin\varphi=y_j+\frac{tk}{2\sqrt{1+k^2}},
456 \end{align*}
457 where $t$ goes from $0$ to $1$, as along the direction of the vector.
458
459 Of macros in \texttt{PSTricks} to draw lines from their parametrization, we select \texttt{\symbol{92}parametricplot}\footnote{\footnotesize
460 This macro is of ones, often added and updated in the package \texttt{pstricks-add}, the authors:
461 Dominique Rodriguez (\texttt{[email protected]}), Herbert Vo\ss\ (\texttt{[email protected]}).}
462 for its fitness. The macro has the syntax
463 $$\textmtt{\symbol{92}parametricplot[{\it settings}]\{$t_{\rm min}$\}\{$t_{\rm max}$\}\{$x(t)$|$y(t)$\}},$$
464 where we may use the option \texttt{algebraic} to make the declaration of $x(t)$ and $y(t)$ simpler
465 in \texttt{ASCII} code.
466
467 From the above description of one field vector, we now construct the vector field
468 on a grid within a domain $R=\{(x,y)\colon a\le x\le b,\,c\le y\le d\}$. To determine the grid, we confine grid points to the range
469 \begin{equation}\label{eqn3}
470 a\le x_i\le b,\quad c\le y_j\le d.
471 \end{equation}
472 We start with initial values $x_0=a$ and $y_0=c$ to have points $(x_i,y_j)$ with increments $\Delta x=\Delta y=\delta$, corresponding to the length of vectors and the distance
473 between grid points as indicated in Figure \ref{Fig5}. Thus, to draw vectors at grid points
474 $(x_i,y_j)$, we need two loops for indices $i$ and $j$, with $0\le i\le\lfloor m/\delta\rfloor$, $0\le j\le\lfloor n/\delta\rfloor$, where
475 $m=b-a$, $n=d-c$. Apparently, these two loops are nested \texttt{\symbol{92}multido}s, with variable declaration
476 for each loop as follows
477 \begin{align*}
478 \texttt{\symbol{92}nx}&=\text{initial value}+\text{increment}=x_0+\Delta x,\\
479 \texttt{\symbol{92}ny}&=\text{initial value}+\text{increment}=y_0+\Delta y.
480 \end{align*}
481 Finally, we will replace \texttt{\symbol{92}nx}, \texttt{\symbol{92}ny} by $x_i$, $y_j$ in the
482 below calling sequence for simplicity.
483
484 Thus, the main command to draw the vector field of the equation (\ref{eqn2}) on the grid (\ref{eqn3})
485 is
486 \begin{align*}
487 &\textmtt{\symbol{92}multido\big\{$y_j=y_0+\Delta y$\big\}\big\{$\lfloor n/\delta\rfloor$\big\}}\textmtt{\bigg\{\symbol{92}multido\big\{$x_i=x_0+\Delta x$\big\}\big\{$\lfloor m/\delta\rfloor$\big\}}\\
488 &\quad\textmtt{\Big\{\symbol{92}parametricplot[{\it settings}]\{$0$\}\{$1$\}\Big\{$x_i+\frac{t}{2\sqrt{1+\big[f(x_i,y_j)\big]^2}}$\Big|
489 $y_j+\frac{tf(x_i,y_j)}{2\sqrt{1+\big[f(x_i,y_j)\big]^2}}$\Big\}\bigg\}}
490 \end{align*}
491 where we at least use \texttt{arrows=->} and \texttt{algebraic} for \textit{settings}.
492
493 We can combine the steps mentioned above to define a drawing procedure, say \texttt{\symbol{92}avecfld},
494 that consists of $6$ parameters in the order as
495 \texttt{\symbol{92}nx=}$x_0+\Delta x$, \texttt{\symbol{92}ny=}$y_0+\Delta y$, $\lfloor m/\delta\rfloor$, $\lfloor n/\delta\rfloor$, $\delta$
496 and $f(\texttt{\symbol{92}nx},\texttt{\symbol{92}ny})$. We may change these values to modify
497 the vector field or to avoid the vector intersection. Such a procedure is suggested to be
498 \bigskip\hrule
499 \noindent\begin{tabular}{@{}l}
500 \verb!\def\avecfld#1#2#3#4#5#6{%!\\
501 \verb!\multido{#2}{#4}{\multido{#1}{#3}!\\
502 \verb!{\parametricplot[algebraic,arrows=->,linecolor=red]{0}{1}!\\
503 \verb!{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}}}}!
504 \end{tabular}\hrule\bigskip
505
506 Actually, the procedure \texttt{\symbol{92}parametricplot} is used here only to draw a vector by its parametrization $(x(t),y(t))$, so we can use the structure \texttt{\symbol{92}curvepnodes} in the package \texttt{pst-node}\footnote{\footnotesize
507 Package authors: Timothy Van Zandt (\texttt{[email protected]}), Michael Sharpe (\texttt{[email protected]}) and Herbert Vo\ss\ (\texttt{[email protected]}).} to
508 extract the two ending points of the curve $(x(t),y(t))$ by the command
509 $$\textmtt{\symbol{92}curvepnodes[algebraic,plotpoints=2]\{0\}\{1\}\{$x(t)$|$y(t)$\}\{P\}},$$
510 where \texttt{P} is a name of the root of nodes and we just get the two nodes \texttt{P0}, \texttt{P1} when executing this command. Then, the corresponding
511 vector is drawn by the command
512 $$\textmtt{\symbol{92}psline[linecolor={\it settings}]\{->\}(P0)(P1)}$$
513
514 Therefore, another procedure to draw a vector field may be defined as
515 \bigskip\hrule
516 \noindent\begin{tabular}{@{}l}
517 \verb!\def\anothervecfld#1#2#3#4#5#6{%!\\
518 \verb!\multido{#2}{#4}{\multido{#1}{#3}!\\
519 \verb!{\curvepnodes[algebraic,plotpoints=2]{0}{1}!\\
520 \verb!{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}{P}!\\
521 \verb!\psline[linecolor=red]{->}(P0)(P1)}}}!
522 \end{tabular}\hrule
523 \subsection{Examples}
524 Firstly, we consider the equation that describes an object falling in a resistive medium:
525 \begin{equation}\label{eqn4}
526 \frac{dv}{dt}=9.8-\frac{v}{5},
527 \end{equation}
528 where $v=v(t)$ is the speed of the object in time $t$. In Figure \ref{Fig6}, the vector field of (\ref{eqn4}) is given
529 on the grid $R=\{(t,y)\colon 0\le t\le 9,\,46\le v\le 52\}$, together with the graph of the equilibrium solution
530 $v=49$.
531 \begin{figure}[htbp]
532 \centering\begin{pspicture}(0,41.4)(8.55,47.25)
533 \psset{xunit=0.9,yunit=0.9}
534 \multido{\ny=46.25+0.50}{13}
535 {\multido{\nx=0.25+0.50}{18}
536 {\curvepnodes[algebraic,plotpoints=2]{0}{1}{\nx+(t/2)*(1/sqrt(1+(9.8-0.2*(\ny))^2))|\ny+(t/2)*(1/sqrt(1+(9.8-(0.2)*(\ny))^2))*(9.8-(0.2)*(\ny))}{P}
537 \psline[linewidth=0.7pt,linecolor=red]{->}(P0)(P1)}}
538 \psplot[algebraic,linewidth=1.2pt]{0}{9.25}{49}
539 \psaxes[labelFontSize=$\footnotesize$,ticksize=2.2pt,labelsep=4pt,Dy=1,Dx=1,Oy=46,linewidth=0.7pt]{->}(0,46)(0,46)(9.5,52.5)
540 \rput(9.5,45.8){$t$}\rput(-0.2,52.5){$y$}
541 \end{pspicture}
542 \caption{The vector field of (\ref{eqn4}).}\label{Fig6}
543 \end{figure}
544
545 Figure \ref{Fig6} is made of the following \LaTeX\ code:
546 \bigskip\hrule
547 \noindent\begin{tabular}{@{}l}
548 \verb!\begin{pspicture}(0,46)(9.5,52.5)!\\
549 \verb!\anothervecfld{\nx=0.25+0.50}{\ny=46.25+0.50}{18}{12}{0.5}{9.8-0.2*\ny}!\\
550 \verb!\psplot[algebraic,linewidth=1.2pt]{0}{9}{49}!\\
551 \verb!\psaxes[Dy=1,Dx=1,Oy=46]{->}(0,46)(0,46)(9.5,52.5)!\\
552 \verb!\rput(9.5,45.8){$t$}\rput(-0.2,52.5){$y$}!\\
553 \verb!\end{pspicture}!
554 \end{tabular}\hrule\bigskip
555
556 Let us next consider the problem
557 \begin{equation}\label{eqn5}
558 \frac{dy}{dx}=x+y,\quad y(0)=0.
559 \end{equation}
560 It is easy to check that $y=e^x-x-1$ is the unique solution to (\ref{eqn5}). We now draw
561 the vector field of (\ref{eqn5}) and the solution curve\footnote{\footnotesize
562 We have used ${\rm ch}(1)+{\rm sh}(1)$ for the declaration of $e$, natural base of logarithmic function.} on the grid $R=\{(x,y)\colon 0\le x\le 3,\,0\le y\le 5\}$ in
563 Figure \ref{Fig7}.
564 \begin{figure}[htbp]
565 \centering\begin{pspicture}(0,0)(3.25,5.5)
566 \psset{unit=1}
567 \multido{\ny=0.25+0.50}{10}
568 {\multido{\nx=0.25+0.50}{6}
569 {\curvepnodes[algebraic,plotpoints=2]{0}{1}{\nx+(t/2)*(1/sqrt(1+(\nx+\ny)^2))|\ny+(t/2)*(1/sqrt(1+(\nx+\ny)^2))*(\nx+\ny)}{P}
570 \psline[linewidth=0.7pt,linecolor=red]{->}(P0)(P1)}}
571 \psplot[algebraic,linewidth=1.2pt]{0}{2.15}{(sh(1)+ch(1))^x-x-1}
572 \psaxes[labelFontSize=$\footnotesize$,Dy=1,Dx=1,ticksize=2.2pt,labelsep=4pt,linewidth=0.7pt]{->}(0,0)(3.5,5.5)
573 \rput(3.5,-0.2){$x$}\rput(-0.25,5.5){$y$}
574 \end{pspicture}
575 \caption{The vector field of (\ref{eqn5}).}\label{Fig7}
576 \end{figure}
577
578 We then go to the logistic equation, which is chosen to be a model for the dependence
579 of the population size $P$ on time $t$ in Biology:
580 \begin{equation}\label{eqn6}
581 \frac{dP}{dt}=kP\Big(1-\frac{P}{M}\Big),
582 \end{equation}
583 where $k$ and $M$ are constants, respectively various to selected species and environment.
584 For specification, we take, for instance, $k=0.5$ and $M=100$. The right hand side of
585 (\ref{eqn6}) then becomes $f(t,P)=0.5\,P(1-0.01\,P)$. In Figure \ref{Fig8}, we draw the vector field
586 of (\ref{eqn6}) on the grid $R=\{(t,P)\colon 0\le t\le 10,\,95\le P\le 100\}$ and the equilibrium
587 solution curve $P=100$. Furthermore, with the initial condition $P(0)=95$, the equation (\ref{eqn6})
588 has the unique solution $P=1900(e^{-0.5t}+19)^{-1}$. This solution curve is also given in Figure \ref{Fig8}.
589 \begin{figure}[htbp]
590 \centering\begin{pspicture}(0,76)(8.4,80.4)
591 \psset{xunit=0.8,yunit=0.8}
592 \multido{\ny=95.25+0.50}{10}
593 {\multido{\nx=0.25+0.50}{20}
594 {\curvepnodes[algebraic,plotpoints=2]{0}{1}{\nx+(t/2)*(1/sqrt(1+((0.5)*(\ny)*(1-(0.01)*(\ny)))^2))|\ny+(t/2)*(1/sqrt(1+((0.5)*(\ny)*(1-(0.01)*(\ny)))^2))*((0.5)*(\ny)*(1-(0.01)*(\ny)))}{P}
595 \psline[linewidth=0.7pt,linecolor=red]{->}(P0)(P1)}}
596 \psplot[algebraic,linewidth=1.2pt]{0}{10.25}{100}
597 \psplot[algebraic,linewidth=1.2pt]{0}{10.25}{1900/((ch(1)+sh(1))^(-0.5*x)+19)}
598 \psaxes[labelFontSize=$\footnotesize$,Dy=1,Dx=1,Oy=95,ticksize=2pt,labelsep=4pt,linewidth=0.7pt]{->}(0,95)(0,95)(10.5,100.5)
599 \rput(10.5,94.8){$t$}\rput(-0.25,100.5){$P$}
600 \end{pspicture}
601 \caption{The vector field of (\ref{eqn6}) with $k=0.5$ and $M=100$.}\label{Fig8}
602 \end{figure}
603
604 The previous differential equations are all of seperated variable or linear cases that
605 can be solved for closed-form solutions by some simple integration formulas. We will consider one more
606 equation of the non-linear case whose solution can only be approximated by numerical methods.
607 The vector field of such an equation is so useful and we will use the Runge-Kutta curves (of order $4$)
608 to add more information about the behaviour of solution curves. Here, those Runge-Kutta curves are depicted by the procedure
609 \texttt{\symbol{92}psplotDiffEqn}, also updated from the package \texttt{pstricks-add}.
610
611 The vector field of the non-linear differential equation
612 \begin{equation}\label{eqn7}
613 \frac{dy}{dx}=y^2-xy+1
614 \end{equation}
615 will be depicted on the grid $R=\{(x,y)\colon -3\le x\le 3,\,-3\le y\le 3\}$ and the solutions
616 of Cauchy problems for (\ref{eqn7}), corresponding to initial conditions
617 \begin{listof}
618 \item $y(-3)=-1$,
619 \item $y(-2)=-3$,
620 \item $y(-3)=-0.4$,
621 \end{listof}
622 will be approximated by the method of Runge-Kutta, with the grid size $h=0.2$. It is very easy
623 to recognize approximate curves, respective to (i), (ii) and (iii) in Figure \ref{Fig9} below.
624 \begin{figure}[htbp]
625 \centering\begin{pspicture}(-3.6,-3.6)(4.2,4.2)
626 \psset{unit=1.2,dotsize=2.6pt}
627 \anothervecfld{\nx=-3.00+0.4}{\ny=-3.00+0.4}{16}{16}{0.35}{(\ny)^2-(\nx)*(\ny)+1}
628 \psplotDiffEqn[linewidth=1.2pt,algebraic,showpoints=true,plotpoints=24,method=rk4]{-3}{1.9}{-1}{(y[0])^2-x*y[0]+1}
629 \psplotDiffEqn[linewidth=1.2pt,algebraic,showpoints=true,plotpoints=25,method=rk4]{-2}{3}{-3}{(y[0])^2-x*y[0]+1}
630 \psplotDiffEqn[linewidth=1.2pt,algebraic,showpoints=true,plotpoints=10,method=rk4]{-3}{-0.96}{-0.4}{(y[0])^2-x*y[0]+1}
631 \psaxes[labelFontSize=$\footnotesize$,Dy=1,Dx=1,ticksize=2.2pt,labelsep=4pt,linewidth=0.7pt]{->}(0,0)(-3,-3)(3.5,3.5)
632 \rput(3.5,-0.2){$x$}\rput(-0.25,3.5){$y$}
633 \end{pspicture}
634 \caption{The vector field of (\ref{eqn7}) and the Runge-Kutta curves.}\label{Fig9}
635 \end{figure}
636 \subsection{Remarks on how to color arrows properly for a vector field}
637 There remains a problem in drawing a vector field. That is coloring arrows.
638 Obviously, their color shade should vary according to their slope and this would give us the picture of domains containing
639 increase or decrease solutions of a differential equation. In some cases, we even know how large the rate of change of those
640 solutions is in a specific domain.
641
642 In Subsection \ref{sect1}, we know for the equation (\ref{eqn2}) that $f(x_i,y_j)$ is right the slope of
643 field vectors at grid points $(x_i,y_j)$, and we will divide these slopes into some number of scales, corresponding to the
644 degree of color shades. Here, we confine our interest to a continuous function $f(x,y)$ in two independent variables on a domain
645 $R=\{(x,y)\colon a\le x\le b,\,c\le y\le d\}$ and choose the scale of $10$ degrees. This number of degrees can be changed to any positive integer.
646
647 According to the input data from the differential equation (\ref{eqn2}), the set $R$ and the grid points on it and the value $M=\max\{|f(x_i,y_j)|\colon
648 0\le i\le\lfloor m/\Delta x\rfloor,\,0\le j\le\lfloor n/\Delta y\rfloor\}$, where $m=b-a$ and $n=d-c$,
649 we can now define the degree of color shade for each arrow in our vector field. It should be an integer $n_{ij}$ such that
650 $n_{ij}=\lfloor 10|f(x_i,y_j)|/M\rfloor$, that is
651 \begin{equation}\label{eqn8}n_{ij}M\le 10|f(x_i,y_j)|<(n_{ij}+1)M.\end{equation}
652 For finding such an integer, in \TeX\ codes, we need one \texttt{\symbol{92}newcount} for it and two \texttt{\symbol{92}newdimen} for
653 $f(x_i,y_j)$ and intermediate values to be compared with $|f(x_i,y_j)|$. For more explanation, let us begin with settings
654 \texttt{\symbol{92}newcount\symbol{92}intg} (referring (ref.) to ``integer''), \texttt{\symbol{92}newdimen\symbol{92}slope} (ref. to ``slope'') and \texttt{\symbol{92}newdimen\symbol{92}interm}
655 (ref. to ``intermediate values''). Then, the integer $n_{ij}$ at stage $(i,j)$ within the two \texttt{\symbol{92}multido} loops can be defined by the recursive macro \texttt{\symbol{92}fintg} (ref. to ``find the integer'') as follows
656 \begin{verbatim}
657 \def\fintg{\interm=Mpt \interm=\intg\interm%
658 \ifdim\ifdim\slope<0pt -\fi\slope<\interm\advance\intg by -1\relax
659 \else\advance\intg by 1\fintg\fi}
660 \end{verbatim}
661 where \texttt{M} and \texttt{\symbol{92}slope} are holding the values $M$ and $f(x_i,y_j)$, respectively. Note that, before running our macro, \verb!\slope! should be multiplied
662 by $10$ with the assignment \texttt{\symbol{92}slope=10\symbol{92}slope}, as defined in (\ref{eqn8}). Besides, by simulating the expression of $f(x,y)$, the calculation of $f(x_i,y_j)$
663 should be declared with operations on \texttt{\symbol{92}newcount}s and \texttt{\symbol{92}newdimen}s. Then, the integer $n_{ij}$, which is found at stage $(i,j)$, should take its
664 degree, say $k$, from $0$ to $10$ by its value, suitably associated to the command \textmtt{\symbol{92}psline[linecolor=red!case-k]\{->\}(P0)(P1)}.
665 Here, we choose \texttt{red} for the main color (it can be changed, of course), and \texttt{case-k} will be replaced with an appropriate percentage of \texttt{red}. Finally,
666 such a color scale is local and relative, so we can use one more parameter in the procedure to adjust color shades.
667 The old procedures take $6$ parameters and the new one will take two more parameters: one for declaration of computing $f(x_i,y_j)$ and the other
668 for adjusting color shades.
669
670 Let us take some examples on how to compute $f(x_i,y_j)$ by \TeX\ codes or by commands from the package \texttt{calculator}\footnote{\footnotesize
671 Package author: Robert Fuster (\texttt{[email protected]}).}. For a simple polynomial $f(x,y)$,
672 computing $f(x_i,y_j)$ by \TeX\ codes might be facile. Because \verb!\nx! and \verb!\ny! are respectively holding values of
673 $x_i$ and $y_j$, we need the two corresponding variables \verb!\newdimen\fx! and \verb!\newdimen\fy! to take these values. By assigning \verb!\fx=\nx pt\fy=\ny pt!,
674 we compute $f(\verb!\nx!,\verb!\ny!)$ and assign its value to \verb!\slope!. The declaration of calculations for some cases of $f(x,y)$ is given in the following table.
675
676 \begin{table}[htbp]
677 \centering\begin{tabular}{c|l}
678 $f(x,y)$&\multicolumn{1}{c}{\TeX\ codes for computing $f(\texttt{\symbol{92}nx},\texttt{\symbol{92}ny})$} \\ \hline
679 $x+y$&\verb!\advance\slope by \fx \advance\slope by \fy!\\ \hline
680 $1-xy$&\verb!\advance\slope by -\decimal\fx\fy \advance\slope by 1pt!\\ \hline
681 $y(3-y)$&\verb!\advance\slope by -\decimal\fy\fy \advance\slope by 3\fy!\\ \hline
682 $y^2-xy$&\verb!\advance\slope by \decimal\fy\fy \advance\slope by -\decimal\fx\fy!\\ \hline
683 \end{tabular}
684 \end{table}
685 In the table, the command \verb!\decimal!, which is quotative from \cite{five} for producing decimal numbers from dimensions, is put in the preamble using a definition as
686 \begin{verbatim}
687 \def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
688 \xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
689 \end{verbatim}
690
691 For a transcendental or rational function $f(x,y)$, we may use the package \texttt{calculator} for
692 computing $f(x_i,y_j)$. The following table shows how to perform calculations.
693 \begin{table}[htbp]
694 \centering\begin{tabular}{c|l}
695 $f(x,y)$&\multicolumn{1}{c}{The commands from the package \texttt{calculator} for computing $f(\texttt{\symbol{92}nx},\texttt{\symbol{92}ny})$} \\ \hline
696 $\sin(y-x)$&\verb!\SUBTRACT{\ny}{\nx}{\sola}\SIN{\sola}{\solb}\slope=\solb pt!\\ \hline
697 \raisebox{-2ex}[0pt][0pt]{$2xy/(1+y^2)$}&\verb!\SUMfunction{\ONEfunction}{\SQUAREfunction}{\Fncty}!\\
698 &\verb!\Fncty{\ny}{\soly}{\Dsoly}\DIVIDE{\Dsoly}{\soly}{\tempa}!\\
699 &\verb!\MULTIPLY{\nx}{\tempa}{\tempb}\slope=\tempb pt!\\ \hline
700 \end{tabular}
701 \end{table}
702
703 From the old macros \verb!\avecfld! or \verb!\anothervecfld!, we will construct the new one \verb!\vecfldnew! by adding up to the former the two parameters as described above. According to
704 the description of new parameters and of known ones, the calling sequence of \verb!\vecfldnew! may have the form of
705 $$\textmtt{\symbol{92}vecfldnew\{\symbol{92}nx$=x_0+\Delta x$\}\{\symbol{92}ny$=y_0+\Delta y$\}\{$n_x$\}\{$n_y$\}\{$\ell$\}\{$f(\texttt{\symbol{92}nx},\texttt{\symbol{92}ny})$\}\{{\rm\TeX\ codes}\}\{$n_a$\}}$$
706 where $n_a$ is an estimate value for $M$ and can be adjusted to be greater or less than $M$. This flexible mechanism might be to increase or decrease the degree of
707 color shades. Finally, \verb!\intg! and \verb!\slope! should be reset to
708 zero at the end of each stage. Now, all materials to make the new macro are ready, and its definition is suggested to be
709 \bigskip\hrule
710 \noindent\begin{tabular}{@{}l}
711 \verb!\def\vecfldnew#1#2#3#4#5#6#7#8{%!\\
712 \verb!\newcount\intg \newdimen\slope \newdimen\interm \newdimen\fx \newdimen\fy!\\
713 \verb!\def\fintg{\interm=#8 \interm=\intg\interm%!\\
714 \verb! \ifdim\ifdim\slope<0pt -\fi\slope>\interm \advance\intg by 1\fintg\fi}!\\
715 \verb!\multido{#2}{#4}!\\
716 \verb!{\multido{#1}{#3}!\\
717 \verb!{\curvepnodes[algebraic,plotpoints=2]{0}{1}!\\
718 \verb!{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}{P}!\\
719 \verb!#7\slope=10\slope \fintg \ifnum\intg>10\psline[linecolor=red]{->}(P0)(P1)!\\
720 \verb+\else\ifnum\intg=0\psline[linecolor=red!5]{->}(P0)(P1)+\\
721 \verb+\else\multiply\intg by 10\psline[linecolor=red!\the\intg]{->}(P0)(P1)\fi\fi+\\
722 \verb+\intg=0\slope=0pt+\\
723 \verb+}}}+
724 \end{tabular}\hrule\bigskip
725
726 If we predefine some scale of degrees, instead of the code $\verb!\ifnum\intg>10!\ldots\verb!\fi\fi!$, the structure \verb!\ifcase! can be used as
727 $$\begin{array}{c}
728 \verb!\ifcase\intg!\\
729 \verb+\psline[linecolor=red!5]{->}(P0)(P1)\or+\\
730 \verb+\psline[linecolor=red!10]{->}(P0)(P1)\or+\\
731 \vdots\\
732 \verb!\psline[linecolor=red]{->}(P0)(P1)\fi!
733 \end{array}$$
734
735 The first example is given with two values of $n_a$ to see how different the color shades are between the two cases. The left vector field in Figure \ref{Fig10}
736 is made of the calling sequence
737 \begin{verbatim}
738 \vecfldnew{\nx=-2.00+0.3}{\ny=-2.00+0.3}{14}{14}{0.3}{(\nx)-2*(\ny)}
739 {\fy=\ny pt \fx=\nx pt \advance\slope by -2\fy \advance\slope by \fx}{7pt}
740 \end{verbatim}
741 \begin{figure}[htbp]
742 \centering\includegraphics[width=4.6cm]{vecb5}
743 \hskip1cm\includegraphics[width=4.6cm]{vecb6}
744 \caption{The vector fields of the equation $y'=x-2y$ with $n_a=\texttt{7pt}$ (the left) and $n_a=\texttt{4pt}$ (the right)}\label{Fig10}
745 \end{figure}
746
747 In Figure \ref{Fig11}, the vector fields of the equations $y'=y-x$ and $y'=x(2-y)$ are respectively drawn by the calling sequences
748 \begin{verbatim}
749 \vecfldnew{\nx=-3.00+0.4}{\ny=-3.00+0.4}{15}{15}{0.35}{(\ny)-(\nx)}
750 {\fy=\ny pt \fx=\nx pt \advance\slope by -\fx \advance\slope by \fy}{5pt}
751 \end{verbatim}
752 and
753 \begin{verbatim}
754 \vecfldnew{\nx=-3.00+0.4}{\ny=-3.00+0.4}{15}{15}{0.35}{(\nx)*(2-(\ny))}
755 {\fy=\ny pt \fx=\nx pt \advance\slope by -\decimal\fx\fy
756 \advance\slope by 2\fx}{6pt}
757 \end{verbatim}
758 \begin{figure}[htbp]
759 \centering\includegraphics[width=6.2cm]{vecb3}
760 \hskip1cm\includegraphics[width=6.2cm]{vecb4}
761 \caption{The vector fields of the equation $y'=y-x$ (the left) and $y'=x(2-y)$ (the right).}\label{Fig11}
762 \end{figure}
763
764 Finally, we consider two more examples on vector fields of differential equations $y'=f(x,y)$ containing trigonometric or rational functions on their right side. The calling sequences
765 \begin{verbatim}
766 \vecfldnew{\nx=-3.00+0.4}{\ny=-3.00+0.4}{15}{15}{0.35}{sin(\nx)*cos(\ny)}
767 {\SIN{\nx}{\tmpa}\COS{\ny}{\tmpb}\MULTIPLY{\tmpa}{\tmpb}{\tmpc}
768 \slope=\tmpc pt}{0.6pt}
769 \end{verbatim}
770 and
771 \begin{verbatim}
772 \vecfldnew{\nx=-3.00+0.3}{\ny=-3.00+0.3}{20}{20}{0.3}{2*(\nx)*(\ny)/(1+(\ny)^2)}
773 {\SUMfunction{\ONEfunction}{\SQUAREfunction}{\Fncty}\Fncty{\ny}{\soly}{\Dsoly}
774 \DIVIDE{\Dsoly}{\soly}{\tempa}\MULTIPLY{\nx}{\tempa}{\tempb}
775 \slope=\tempb pt}{2.5pt}
776 \end{verbatim}
777 respectively result in the vector fields on the left and on the right in Figure \ref{Fig12}.
778
779 \begin{figure}[htbp]
780 \centering\includegraphics[width=6.2cm]{vecb1}
781 \hskip1cm\includegraphics[width=6.2cm]{vecb2}
782 \caption{The vector fields of the equation $y'=\sin(x)\cos(y)$ (the left) and $y'=2xy/(1+y^2)$ (the right).}\label{Fig12}
783 \end{figure}
784 \section{Drawing partitions of a simply connected plane domain}
785 \subsection{Description}
786 B\'{e}zier curves have been used in many different aspects, but mostly in computer graphics to model smooth curves designed by computer
787 programs. We just recall here the vector function of a B\'{e}zier curve of degree $n$ with $n+1$ control points whose position
788 vectors are $\mathbf{r}_0$, $\mathbf{r}_1$, \dots, $\mathbf{r}_n$. It is the vector function $\mathbf{r}(t)$ in a real variable $t\in[0,1]$ that
789 is defined as
790 \begin{equation}\label{eqn9}
791 \mathbf{r}(t)=\sum_{i=0}^n\binom{n}{i}t^i(1-t)^{n-i}\mathbf{r}_i.
792 \end{equation}
793 Since $\mathbf{r}(0)=\mathbf{r}_0$, $\mathbf{r}(1)=\mathbf{r}_n$ and $\mathbf{r}'(0)=n(\mathbf{r}_1-\mathbf{r}_0)$, $\mathbf{r}'(1)=n(\mathbf{r}_n-\mathbf{r}_{n-1})$,
794 we can take a curve such that it is closed and tangent to a line $(\Delta)$ at the point whose position vector is $\mathbf{r}_0$, by
795 letting $\mathbf{r}_n=\mathbf{r}_0$ and the points whose position vectors are $\mathbf{r}_0$, $\mathbf{r}_1$ and $\mathbf{r}_{n-1}$
796 all be on the line $(\Delta)$.
797
798 Taking a closed B\'{e}zier curve to be the boundary of a plane domain has the great advantage. That is because coordinates of points
799 on the curve are evaluated by polynomials, and the curve has necessary smoothness, beautiful enough for graphic illustrations.
800 \texttt{PSTricks} has the procedure \verb!\parametricplot! to draw such a curve. But, an important problem here is how to control
801 the coordinates of its points to construct a procedure for drawing a partition of a simply connected plane domain and coloring
802 (or marking) its cells having common points with the boundary of the domain. We particularly need such a procedure for illustrations
803 of essential notions in measure theory or double integral definition. Because of the limitation in accuracy imposed
804 by the \TeX\ arithmetic, we should mention about $2$-dimension vector functions of a B\'{e}zier curve of small degree (in fact, as small as possible).
805 According to the above requirements for the closed boundary of a simply connected domain, we will design a family of closed B\'{e}zier curves of
806 degree $6$, although we may extend their degree to $12$.
807
808 From the expression of $\mathbf{r}(t)$ in (\ref{eqn9}), we will construct the following functions and procedures:
809 \begin{itemize}
810 \item The factorial function \texttt{FACTORIAL}.
811 \item The binomial function \texttt{BINOMIAL}.
812 \item Polynomials $t^m(1-t)^n$.
813 \item A procedure to compute a sum of $7$ terms: values of $\mathbf{r}(t)$ as linear combinations
814 of the Bernstein polynomials
815 $$\binom{6}{k}t^k(1-t)^{6-k},\quad k=0,\ldots,6.$$
816 \end{itemize}
817 These functions and procedures are macros given by definitions with or without parameters. In the following subsections we will construct them step by step and
818 show how to make connections between them.
819 \subsubsection{Factorial functions and binomial coefficients}
820 To obtain the factorial function, a procedure for multiplying consecutively an integer $n$ with its diminished values will be constructed. For the declared
821 integer variables \verb!\Fa! and \verb!\Fct!, the latter will hold values of the function, and the former will hold factors that are multiplied consecutively
822 and reduced by $1$. Namely, if \verb!\Fa! is $0$ or $1$ then \verb!\Fct! takes $1$; else if $\texttt{\symbol{92}Fa}>1$ then \verb!\Fct! takes
823 the initial value of \verb!\Fa! to begin a loop: diminishing \verb!\Fa! by $1$ and updating \verb!\Fct! by multiplying its old value with the new value of \verb!\Fa!.
824 The loop is defined by the control sequence \verb!\Factor! and is ended when \verb!\Fa! is diminished to $1$; then, the factorial function obtains its value from
825 the one given back after calling \verb!\FACTORIAL! with one parameter.
826 \begin{verbatim}
827 \newcount\Fa\newcount\Fct
828 \newcount\tempA
829 \def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
830 \def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa \Factor\fi%
831 \global\tempA=\Fct}
832 \end{verbatim}
833 Since \TeX\ limits the largest integer number to $2^{30}-1$, we can evaluate only to
834 $$\textmtt{\symbol{92}FACTORIAL\{$12$\}}=12!=479001600.$$
835 Besides, the last value of \verb!\Fct!, which is right the one obtained from calling the function, is assigned to a global integer variable \verb!\tempA! for use
836 in other procedures. Finally, make the calling sequence
837 $$\textmtt{\symbol{92}FACTORIAL\{k\}\symbol{92}the\symbol{92}Fct}$$
838 to obtain and show up the value of $k!$. From these values we derive binomial coefficients by the formula
839 $$\binom{m}{n}=\frac{m!}{n!(m-n)!}.$$
840 A simple procedure that makes division of $m!$ by $n!$, then of the result by $(m-n)!$ can be performed by the control sequence
841 \verb!\BINOMIAL! with two parameters as follows
842 \begin{verbatim}
843 \newcount\BINOM
844 \newcount\temp\newcount\tmp
845 \def\BINOMIAL#1#2{%
846 \temp=#1\advance\temp by -#2
847 \FACTORIAL{#1}
848 \tmp=\tempA
849 \FACTORIAL{\temp}
850 \temp=\tempA
851 \divide\tmp by \temp
852 \FACTORIAL{#2}
853 \temp=\tempA
854 \divide\tmp by \temp\global\BINOM=\tmp}
855 \end{verbatim}
856 Again, the last value of \verb!\tmp! is assigned to a global integer variable \verb!\BINOM! for later use. Because the vector function of a B\'{e}zier
857 curve of degree $6$ is only needed, so are the binomial coefficients \verb!\BINOMIAL{!$6$\verb!}{!$k$\verb!}!, $k=0,1,\ldots,6$.
858 \subsubsection{Bernstein polynomials}
859 The construction of Bernstein functions is based on an iterative multiplication of the same value $t$ by a given number $m$ of times,
860 then the process is repeated with the value $1-t$ by a given number $n$ of times. The last result is multiplied by a variable that holds
861 the value of $\binom{m+n}{m}$. We will use an integer variable \verb!\kc! to count times of multiplication for the same factor $t$ or $1-t$.
862 The procedure of iterative multiplication \verb!\xmult! with one parameter $m$ or $n$ is a recursive one that is performed
863 iteratively until \verb!\kc! reaches the value $m$ or $n$.
864 \begin{verbatim}
865 \newdimen\Xa\newdimen\Yb\newcount\kc
866 \def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}
867 \else\relax\fi}
868 \end{verbatim}
869 Finally, the value of $t^m(1-t)^n$ that is hold by the variable \verb!\Yb! is multiplied by \verb!\BINOM!, the value $\binom{6}{m}$.
870 Thus, Bernstein polynomials are given by the following macro \verb!\BERNSTEIN! with three parameters that hold values of
871 $m$, $n$ and $t$, respectively.
872 \begin{verbatim}
873 \newdimen\BSTemp
874 \def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa
875 \advance\Xa by 1pt\xmult{#2}\BINOMIAL{6}{#1}\global\BSTemp=\BINOM\Yb}
876 \end{verbatim}
877 Also, values of \verb!\BERNSTEIN! are assigned to a global variable.
878 \subsubsection{Vector functions of a plane B\'{e}zier curve of degree $6$}
879 We will construct here the vector function of a plane and closed B\'{e}zier curve with the control points
880 $M_0(x_0,y_0)$, $M_1(x_1,y_1)$, \dots, $M_6(x_6,y_6)$ that is chosen in such a way that the curve is tangent to
881 a line $(\Delta)$ at its initial point $M_0$. According to the mentioned properties of a B\'{e}zier curve, the requirements
882 for the curve are satisfied when $M_6=M_0$ and $M_0$, $M_1$, $M_5$ are all on the line $(\Delta)$.
883 \begin{figure}[htbp]
884 \centering\begin{pspicture}(0,0)(5,4.3)
885 \psset{unit=0.6cm}
886 \newcount\pos\def\drawpts#1#2{\newdimen\xrp\xrp=2pt\newdimen\yrp\yrp=2pt\advance\xrp by #1pt\advance\yrp by #2pt\psdot(\decimal\xrp,\decimal\yrp)
887 \rput[rt](\decimal\xrp,\decimal\yrp){$M_{\the\pos}$}\advance\pos by 1}
888 \drawpts{0}{0}\drawpts{-1.5}{2}\drawpts{2}{5}\drawpts{6}{3}\drawpts{5}{-1}\drawpts{1.5}{-2}
889 \parametricplot[algebraic,linewidth=0.5pt]{0}{0.5}{\XBsix{2}{1}|\YBsix{2}{1}}
890 \parametricplot[algebraic,linewidth=0.5pt]{0.5}{1}{\XBsix{2}{1}|\YBsix{2}{1}}
891 \psline[linewidth=0.2pt](0.5,4)(3.5,0)
892 \end{pspicture}
893 \caption{A B\'{e}zier curve of degree $6$ with the required control points.}\label{Fig13}
894 \end{figure}
895 In case $n=6$, from (\ref{eqn9}) we derive the vector function $\mathbf{r}(t)$ with the two components
896 \begin{equation}\label{eqn10}
897 X(t)=\sum_{i=0}^6\binom{6}{i}t^i(1-t)^{6-i}x_i,\quad Y(t)=\sum_{i=0}^6\binom{6}{i}t^i(1-t)^{6-i}y_i.
898 \end{equation}
899 We first evaluate values of $X(t)$ by the procedures that just have been constructed, with a choice of $x_i$, $i=1,\ldots,6$, from a given $x_0$
900 and the requirements of the B\'{e}zier curve as in Figure \ref{Fig13}. For example, we may take
901 $$x_1=x_0-1.5,\quad x_2=x_0+2,\quad x_3=x_0+6,\quad x_4=x_0+5,\quad x_5=x_0+1.5,\quad x_6=x_0.$$
902 Moreover, we may change the shape of the curve by taking a factor $\alpha$ for $X(t)$. In short, we will make a procedure to evaluate the sum of terms
903 $\binom{6}{i}t^i(1-t)^{6-i}(\alpha x_i)$, $i=0,1,\ldots,6$. In fact, it is a procedure to add up values into a global variable \verb!\XBST! that is called
904 by a macro \verb!\XBC! with three declaring parameters for $x_i$, $t$ and $\alpha$. The value of $\alpha$ is used last when being multiplied by a
905 variable that holds $X(t)$. Such a procedure is suggested to be the following macro
906 \begin{verbatim}
907 \newdimen\Xrf\newdimen\Yrf
908 \newdimen\XBST\newdimen\YBST
909 \def\XBC#1#2#3{%
910 \BERNSTEIN{0}{6}{#2}
911 \Xrf=#1pt
912 \XBST=\decimal\BSTemp\Xrf
913 \BERNSTEIN{1}{5}{#2}
914 \Xrf=#1pt\advance\Xrf by -1.5pt
915 \advance\XBST by \decimal\BSTemp\Xrf
916 \BERNSTEIN{2}{4}{#2}
917 \Xrf=#1pt\advance\Xrf by 2pt
918 \advance\XBST by \decimal\BSTemp\Xrf
919 \BERNSTEIN{3}{3}{#2}
920 \Xrf=#1pt\advance\Xrf by 6pt
921 \advance\XBST by \decimal\BSTemp\Xrf
922 \BERNSTEIN{4}{2}{#2}
923 \Xrf=#1pt\advance\Xrf by 5pt
924 \advance\XBST by \decimal\BSTemp\Xrf
925 \BERNSTEIN{5}{1}{#2}
926 \Xrf=#1pt\advance\Xrf by 1.5pt
927 \advance\XBST by \decimal\BSTemp\Xrf
928 \BERNSTEIN{6}{0}{#2}
929 \Xrf=#1pt
930 \advance\XBST by \decimal\BSTemp\Xrf
931 \global\XBST=#3\XBST}
932 \end{verbatim}
933 In the macro, a control sequence of the form \verb!\decimal\Xdim! is for obtaining the decimal value of a variable \verb!\Xdim! without units
934 (\verb!pt!, by default). This can be defined by
935 \begin{verbatim}
936 \def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
937 \xch \def\dec#1pt{#1}\ych \gdef\decimal#1{\expandafter\dec \the#1}
938 \end{verbatim}
939 Besides, the last line in the definition of \verb!\XBC! (\verb!\global\XBST=#3\XBST!) signifies \verb!\XBST! is adjusted for multiplication by
940 $\alpha$ when holding the current value of the sum $X(t)$. In Table \ref{bc-Table1}, some values
941 of \verb!\XBC! are compared with those of a simpler procedure in Maple\footnote{\footnotesize Maple
942 is a computer algebra system. It was first developed in 1980 by the Symbolic Computation Group at the University of
943 Waterloo in Waterloo, Ontario, Canada. Maple supports numeric and symbolic computations
944 and can be used as a programming language, which resembles Pascal.}.
945 \begin{table}[htbp]
946 \centering\begin{tabular}{|c|c|c|c|c|c|}\hline
947 &$(-2.4,0.23,1.5)$&$(4.2,0.45,1.1)$&$(-3.4,0.7,1.24)$&$(-0.89,0.4,1.5)$&$(5.21,0.5,2.15)$\\ \hline
948 \texttt{\symbol{92}XBC}&$\XBC{-2.4}{0.23}{1.5}\decimal\XBST$&$\XBC{4.2}{0.45}{1.1}\decimal\XBST$&$\XBC{-3.4}{0.7}{1.24}\decimal\XBST$&$\XBC{-0.89}{0.4}{1.5}\decimal\XBST$&$\XBC{5.21}{0.5}{2.15}\decimal\XBST$\\ \hline
949 Maple&$-2.41044$&$8.13235$&$-0.13696$&$2.78628$&$18.76008$\\ \hline
950 \end{tabular}
951 \caption{A comparison between some values of \textmtt{\symbol{92}XBC} and those of a procedure in Maple.}\label{bc-Table1}
952 \end{table}
953
954 Likewise, from a given $y_0$, we may have a choice of $y_i$, $i=1,\ldots,6$, as follows
955 $$y_1=y_0+2,\quad y_2=y_0+5,\quad y_3=y_0+3,\quad y_4=y_0-1,\quad y_5=y_0-2,\quad y_6=y_0.$$
956 The macro \verb!\YBC! is constructed in a quite analogous way as for \verb!\XBC! to evaluate values of $Y(t)$ in (\ref{eqn10}),
957 and the value $\beta Y(t)$ ($\beta$ is again an adjustment factor) is hold by a global variable \verb!\YBST!.
958
959 \subsubsection{Partition of a simply connected plane domain by a rectangular grid}
960
961 We consider here a simply connected plane domain $D$ surrounded by a B\'{e}zier curve of degree $6$ that will be depicted by
962 the procedure \verb!\NetDraw!. This is called together with its five parameters whose values are assigned to the five local variables
963 with their following meaning:
964 \begin{align*}
965 \texttt{\symbol{92}CellNum:}&\text{ The number of horizontal and vertical cells of the grid.}\\
966 \texttt{\symbol{92}Xref:}&\text{ The value of $x_0$.}\\
967 \texttt{\symbol{92}Yref:}&\text{ The value of $y_0$.}\\
968 \texttt{\symbol{92}Xfact:}&\text{ The value of $\alpha$.}\\
969 \texttt{\symbol{92}Yfact:}&\text{ The value of $\beta$.}
970 \end{align*}
971 We denote by $R$ a rectangular domain containing $D$ and having edges parallel to the coordinate axes.
972 A grid of rectangular cells will be depicted on $R$. According to the given values of $x_0$, $y_0$, $\alpha$ and $\beta$, the vertices of $R$
973 can be chosen as the points $(\verb!\XMin!,\verb!\YMax!)$, $(\verb!\XMax!,\verb!\YMax!)$, $(\verb!\XMax!,\verb!\YMin!)$, $(\verb!\XMin!,\verb!\YMin!)$, where
974 \begin{align*}
975 \textmtt{\symbol{92}XMin}&=\alpha(\textmtt{\symbol{92}Xref}-1.5),&&\textmtt{\symbol{92}XMax}=\alpha(\textmtt{\symbol{92}Xref}+6),\\
976 \textmtt{\symbol{92}YMin}&=\beta(\textmtt{\symbol{92}Yref}-2),&&\textmtt{\symbol{92}YMax}=\beta(\texttt{\symbol{92}Yref}+5).
977 \end{align*}
978 Then, the horizontal step size \verb!\Xsize! and the vertical step
979 size \verb!\Ysize! may be taken as
980 $$\mtt\\\texttt{Xsize}=\frac{\mtt\\\texttt{XMax}-\mtt\\\texttt{XMin}}{\mtt\\\texttt{CellNum}},\quad
981 \mtt\\\texttt{Ysize}=\frac{\mtt\\\texttt{YMax}-\mtt\\\texttt{YMin}}{\mtt\\\texttt{CellNum}}.$$
982
983 At first, the grid is made by using the structure \verb!\multido! to draw vertical and horizontal lines whose equations are
984 $$x=\texttt{\symbol{92}XMin}+i\texttt{\symbol{92}Xsize},\quad
985 y=\texttt{\symbol{92}YMin}+i\texttt{\symbol{92}Ysize},\quad i=0,\ldots,\texttt{\symbol{92}CellNum}.$$
986 Next, the B\'{e}zier curve is depicted by the command
987 $$\textmtt{\symbol{92}parametricplot[algebraic,fillstyle=solid]\{$0$\}\{$1$\}\{$\alpha X(t)$|$\beta Y(t)$\}}$$
988 and it is approximated by the sequence of points $(X_i,Y_i)$, $i=1,\ldots,N$, where $X_i$ and $Y_i$ are given from
989 the calling sequences
990 $$\textmtt{\symbol{92}XBC\{\symbol{92}XRef\}\{$t_i$\}\{\symbol{92}Xfact\}},\quad
991 \textmtt{\symbol{92}YBC\{\symbol{92}YRef\}\{$t_i$\}\{\symbol{92}Yfact\}}.$$
992
993 Finally, the most important algorithm is to determine cells that have points in common with the B\'{e}zier curve,
994 and to color them. The chosen ``filter'' method here can be described as follows: for each point $(X_i,Y_i)$ of the approximate sequence,
995 $i=1,\ldots, N$, we examine cells from left to right in horizontal direction, and from below to above in vertical direction. As soon as
996 being found, the cell containing $(X_i,Y_i)$ is specifically colored by the command \textmtt{\mtt\\pspolygon[fillstyle=solid,$\ldots$]} passing its four
997 vertices; then, we examine the next point $(X_{i+1},Y_{i+1})$, and so on. Actually, a structure of three nested \verb!\multido! loops
998 is used to perform this filter method, and the loop for counting points $(X_i,Y_i)$ is the most outer one. The algorithm to examine if
999 a cell contains $(X_i,Y_i)$ may have the form of
1000 \begin{verbatim}
1001 \ifdim\YBST<y\relax\else\advance y by \Ysize
1002 \ifdim\YBST>y\relax\else
1003 \ifdim\XBST<x\relax\else\advance x by \Xsize
1004 \ifdim\XBST>x\relax\else
1005 \pspolygon[fillstyle=solid,fillcolor=red]
1006 (x,y)(x+\Xsize,y)(x+\Xsize,y+\Ysize)(x,y+\Ysize)(x,y)\relax
1007 \fi\fi\fi\fi
1008 \end{verbatim}
1009 The single characters ``\verb!x!'', ``\verb!y!'' and the opertation ``\verb!+!'' will be replaced appropriately in the procedure \verb!\NetDraw! below.
1010 For increasingly chosen values of $N$, we may know if the set of cells having points in common with the curve can cover the curve itself?
1011 On the other hand, to increase the number of approximate points is corresponding to reduce the increment in the most outer loop \verb!\multido!.
1012 For instance, if we take $N=100$, then the variable \verb!\nz! in the loop should be declared as $\texttt{\mtt\\nz}=0.00+0.01$ because
1013 $t_i\in[0,1]$.
1014
1015 In summary, to illustrate a partition of a simply connected plane domain, we can apply the following procedure \verb!\NetDraw!. As mentioned above,
1016 step by step, \verb!\NetDraw! can: draw the boundary of a plane domain $D$ by a B\'{e}zier curve of degree $6$, draw a partition of a rectangle $R$ containing $D$
1017 by a grid of rectangular cells, and color cells having points in common with the boundary of $D$.
1018 \bigskip
1019 %\vskip2ex
1020 \hrule
1021 \begin{verbatim}
1022 \def\NetDraw#1#2#3#4#5{%
1023 \newcount\CellNum
1024 \newdimen\XRef
1025 \newdimen\YRef
1026 \newdimen\Xfact
1027 \newdimen\Yfact
1028 \newdimen\XMin
1029 \newdimen\XMax
1030 \newdimen\YMin
1031 \newdimen\YMax
1032 \newdimen\Xsize
1033 \newdimen\Ysize
1034 \newdimen\tempx
1035 \newdimen\tempy
1036 \CellNum=#1
1037 \XRef=#2pt
1038 \YRef=#3pt
1039 \Xfact=#4pt
1040 \Yfact=#5pt
1041 \XMin=\decimal\Xfact\XRef \advance\XMin by -1.50\Xfact
1042 \XMax=\decimal\Xfact\XRef \advance\XMax by 6.00\Xfact
1043 \YMin=\decimal\Yfact\YRef \advance\YMin by -2.00\Yfact
1044 \YMax=\decimal\Yfact\YRef \advance\YMax by 5.00\Yfact
1045 \Xsize=\XMax \advance\Xsize by -\XMin \divide\Xsize by \CellNum
1046 \Ysize=\YMax \advance\Ysize by -\YMin \divide\Ysize by \CellNum
1047 \parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!80,plotpoints=200,
1048 linewidth=0.5pt]{0}{1}{\XBsix{\decimal\XRef}{\decimal\Xfact}|
1049 \YBsix{\decimal\YRef}{\decimal\Yfact}}
1050 \multido{\nz=0.00+0.005}{200}{\XBC{\decimal\XRef}{\nz}{\decimal\Xfact}
1051 \YBC{\decimal\YRef}{\nz}{\decimal\Yfact}
1052 \multido{\nx=\decimal\XMin+\decimal\Xsize}{\the\CellNum}
1053 {\tempx=\nx pt\multido{\ny=\decimal\YMin+\decimal\Ysize}{\the\CellNum}
1054 {\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize%
1055 \ifdim\YBST>\tempy\relax\else
1056 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
1057 \ifdim\XBST>\tempx\relax\else
1058 \pspolygon[fillstyle=solid,fillcolor=blue!90,linecolor=black,
1059 linewidth=0.2pt]
1060 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)
1061 (\nx,\decimal\tempy)(\nx,\ny)\relax\fi\fi\fi\fi}
1062 }}
1063 \advance\CellNum by 1
1064 \multido{\nx=\decimal\XMin+\decimal\Xsize}{\the\CellNum}
1065 {\psline[linewidth=0.2pt](\nx,\decimal\YMax)(\nx,\decimal\YMin)}
1066 \multido{\ny=\decimal\YMin+\decimal\Ysize}{\the\CellNum}
1067 {\psline[linewidth=0.2pt](\decimal\XMin,\ny)(\decimal\XMax,\ny)}
1068 \parametricplot[algebraic,linecolor=white,plotpoints=200,linewidth=0.5pt]{0}{1}
1069 {\XBsix{\decimal\XRef}{\decimal\Xfact}|\YBsix{\decimal\YRef}{\decimal\Yfact}}}
1070 \end{verbatim}\hrule\bigskip
1071
1072 In the definition of \verb!\NetDraw!, the expressions $\alpha X(t)$, $\beta Y(t)$ are declared in the \verb!algebraic! form by the macros \verb!\XBsix!,
1073 \verb!\YBsix! with two parameters that hold values of $x_0,\alpha$ and $y_0,\beta$, respectively. These macros are given by
1074 the following definitions:
1075 \begin{verbatim}
1076 \def\XBsix#1#2{%
1077 (1-t)^6*(#1)*(#2)+6*t*(1-t)^5*(#1-1.5)*(#2)+15*t^2*(1-t)^4*(#1+2)*(#2)+
1078 20*t^3*(1-t)^3*(#1+6)*(#2)+15*t^4*(1-t)^2*(#1+5)*(#2)+
1079 6*t^5*(1-t)*(#1+1.5)*(#2)+t^6*(#1)*(#2)}
1080 \def\YBsix#1#2{%
1081 (1-t)^6*(#1)*(#2)+6*t*(1-t)^5*(#1+2)*(#2)+15*t^2*(1-t)^4*(#1+5)*(#2)+
1082 20*t^3*(1-t)^3*(#1+3)*(#2)+15*t^4*(1-t)^2*(#1-1)*(#2)+
1083 6*t^5*(1-t)*(#1-2)*(#2)+t^6*(#1)*(#2)}
1084 \end{verbatim}
1085 \subsection{Examples}
1086 Firstly, let us see the effect of change for the shape of a domain when adjusting its boundary by taking different values of $\alpha$ and $\beta$. The
1087 calling sequence for this purpose may have the form of
1088 \begin{align*}
1089 &\textmtt{\mtt\\parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]\{$0$\}\{$1$\}}\\
1090 &\textmtt{\mtt\{XBsix\{$x_0$\}\{$\alpha$\}|\mtt\\YBsix\{$y_0$\}\{$\beta$\}\mtt\}}
1091 \end{align*}
1092 and its result is given in Figure \ref{Fig14}.
1093 \begin{figure}[htbp]
1094 \centering\begin{pspicture}(0,0.5)(3.5,3)
1095 \psset{unit=12pt}
1096 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}{\XBsix{2}{1.5}|\YBsix{2}{1.5}}
1097 \end{pspicture}
1098 \begin{pspicture}(0,0.5)(5,3.5)
1099 \psset{unit=12pt}
1100 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}{\XBsix{2}{2}|\YBsix{2}{1.5}}
1101 \end{pspicture}
1102 \begin{pspicture}(0,1)(4,3.5)
1103 \psset{unit=12pt}
1104 \parametricplot[algebraic,plotpoints=200,linewidth=0.5pt]{0}{1}{\XBsix{2}{1.5}|\YBsix{2}{2}}
1105 \end{pspicture}
1106 \caption{From left to right, corresponding to the couple of values:
1107 $\alpha=2,\,\beta=2$; $\alpha=2.5,\,\beta=2$; $\alpha=2,\,\beta=2.5$.}\label{Fig14}
1108 \end{figure}
1109
1110 The Table \ref{bc-table2} below provides three partitions of a domain $D$ with cells that decrease in size. In each case, \verb!\NetDraw! can
1111 determine the cells that have points in common with the boundary curve and color them. The calling sequence here
1112 takes a simple form
1113 $$\textmtt{\mtt\\NetDraw\{$c$\}\{$x_0$\}\{$y_0$\}\{$\alpha$\}\{$\beta$\}}$$
1114 The numerical argument $c$ is assigned to the local variable \verb!\CellNum!. The number of approximate points $(X_i,Y_i)$ for the boundary curve
1115 is chosen to be $200$, by default, corresponding to the increment $\Delta\mtt{z}=0.005$. The number $N$ can be made larger and the filter procedure
1116 for determining required cells may be more exact. In Table \ref{bc-table2}, the B\'{e}zier curves are depicted with the choice
1117 $x_0=y_0=\alpha=\beta=2$.
1118 \begin{table}[htbp]
1119 \centering\begin{tabular}{cc}
1120 \includegraphics[width=6cm]{b6of1}&\includegraphics[width=6cm]{b6of2}\\
1121 \includegraphics[width=6cm]{b6of3}&\includegraphics[width=6cm]{b6of4}
1122 \end{tabular}
1123 \caption{The partitions of $D$ with $c=18$, $c=36$ and $c=63$.}\label{bc-table2}
1124 \end{table}
1125
1126 \acknw
1127 I am very grateful to
1128 \begin{itemize}
1129 \item Timothy Van Zandt, Herbert Vo\ss, Dominique Rodriguez and Michael Sharpe for helping me with
1130 their great works on \texttt{PSTricks}.
1131 \item H\`an Th\hantt\rlap\accentcircflx\ Th\`anh for helping me with his pdf\hskip.03em\LaTeX\ program.
1132 \item Robert Fuster for his very useful package \texttt{calculator}.
1133 \end{itemize}
1134 \begin{thebibliography}{10}
1135 \bibitem{one} Dominique Rodriguez, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pstricks-add}: Additional Macros for PSTricks\/}.
1136 Version 3.60,
1137 \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
1138 \bibitem{two} Timothy Van Zandt, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pst-node}: Nodes and node connections}.
1139 Version 1.29,
1140 \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
1141 \bibitem{three} Helmut Kopka \&\ Patrick W. Daly. \textsl{Guide to \LaTeX \/}.
1142 Addison-Wesley, Fourth Edition, 2004, ISBN 0321173856
1143 \bibitem{four} Timothy Van Zandt. \textsl{User's Guide\/}. Version 1.5,\\
1144 \url{http://ctan.org/tex-archive/graphics/pstricks/base}, 2007
1145 \bibitem{five}Eitan M. Gurari. \textsl{Writing With \TeX \/}, McGraw-Hill, Inc., 1994, ISBN 0-07-025207-6
1146 \bibitem{six} Robert Fuster. \textsl{\texttt{calculator-calculus}: Scientific Calculations With \LaTeX \/}. Version 1.0a,
1147 \url{http://ctan.org/tex-archive/macros/latex/contrib/calculator}, 2012
1148 \end{thebibliography}
1149
1150 \end{document}
1151 \begin{thebibliography}{10}
1152 \bibitem{one} Dominique Rodriguez, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pstricks-add}: Additional Macros for PSTricks\/}.
1153 Version 3.60,
1154 \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
1155 \bibitem{two} Timothy Van Zandt, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pst-node}: Nodes and node connections}.
1156 Version 1.29,
1157 \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
1158 \bibitem{three} Helmut Kopka \&\ Patrick W. Daly. \textsl{Guide to \LaTeX \/}.
1159 Addison-Wesley, Fourth Edition, 2004, ISBN 0321173856
1160 \bibitem{four} Timothy Van Zandt. \textsl{User's Guide\/}. Version 1.5,\\
1161 \url{http://ctan.org/tex-archive/graphics/pstricks/base}, 2007
1162 \bibitem{five}Eitan M. Gurari. \textsl{Writing With \TeX \/}, McGraw-Hill, Inc., 1994, ISBN 0-07-025207-6
1163 \bibitem{six} Robert Fuster. \textsl{\texttt{calculator-calculus}: Scientific Calculations With \LaTeX \/}. Version 1.0a,
1164 \url{http://ctan.org/tex-archive/macros/latex/contrib/calculator}, 2012
1165 \end{thebibliography}