summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/NewVecFld_PDF.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/NewVecFld_PDF.tex')
-rw-r--r--Master/texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/NewVecFld_PDF.tex572
1 files changed, 572 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/NewVecFld_PDF.tex b/Master/texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/NewVecFld_PDF.tex
new file mode 100644
index 00000000000..53289e4656d
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pstricks_calcnotes/For_Pdf_Output/NewVecFld_PDF.tex
@@ -0,0 +1,572 @@
+\documentclass[11pt,a4paper,oneside]{article}
+\usepackage{calculator}
+\usepackage{calculus}
+\usepackage{amsthm}
+\usepackage{amsmath}
+\usepackage[dvips]{geometry}
+\usepackage{pstricks}
+\usepackage{graphicx}
+\usepackage{graphics}
+\usepackage{pst-plot}
+\usepackage{pst-node}
+\usepackage{multido}
+\usepackage{pst-xkey}
+\usepackage{pst-func}
+\usepackage{pstricks-add}
+\usepackage[colorlinks,linktocpage]{hyperref}
+\def\hantt{\^e}\def\accentcircflx{\hskip-.3em\raisebox{0.32ex}{\'{}}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\RiemannSum#1#2#3#4#5#6#7#8#9{%
+\psplot[linecolor=blue]{#1}{#2}{#3}
+\pscustom[linecolor=red]{%
+\psline{-}(#1,0)(#1,0)
+\multido{\ni=#5,\ne=#6}{#4}
+{\psline(*{\ni} {#8})(*{\ne} {#9})}}
+\multido{\ne=#6,\nc=#7}{#4}
+{\psdot(*{\nc} {#3})
+\psline[linestyle=dotted,dotsep=1.5pt](\nc,0)(*{\nc} {#3})
+\psline[linecolor=red](\ne,0)(*{\ne} {#9})}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\vecfld#1#2#3#4#5#6{%
+\multido{#2}{#4}
+{\multido{#1}{#3}
+{\parametricplot[algebraic,arrows=->,linecolor=red]{0}{1}
+{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}}}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
+\xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\vecfldnew#1#2#3#4#5#6#7#8{%
+\newcount\intg \newdimen\fx \newdimen\fy \newdimen\slope \newdimen\interm
+\def\fintg{\interm=#8 \interm=\intg\interm \ifdim\ifdim\slope<0pt-\fi\slope>\interm\advance\intg by 1\fintg\fi}
+\multido{#2}{#4}
+{\multido{#1}{#3}
+{\curvepnodes[algebraic,plotpoints=2]{0}{1}{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}{P}
+#7 \slope=10\slope\fintg
+\ifnum\intg>10\psline[linecolor=red]{->}(P0)(P1)\else\ifnum\intg=0\psline[linecolor=red!5]{->}(P0)(P1)\else\multiply\intg by 10
+\psline[linecolor=red!\the\intg]{->}(P0)(P1)\fi\fi
+\intg=0\slope=0pt
+}}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\pagestyle{headings}
+\topmargin=-0.6cm
+\textwidth=16.7cm
+\textheight=23cm
+\headheight=2.5ex
+\headsep=0.6cm
+\oddsidemargin=.cm
+\evensidemargin=-.4cm
+\parskip=0.7ex plus0.5ex minus 0.5ex
+\baselineskip=17pt plus2pt minus2pt
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\catcode`@=11
+\renewcommand\section{\@startsection {section}{1}{\z@}%
+ {-3.5ex \@plus -1ex \@minus -.2ex}%
+ {2.3ex \@plus.2ex}%
+ {\normalfont\large\bfseries}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-3.25ex\@plus -1ex \@minus -.2ex}%
+ {1.5ex \@plus .2ex}%
+ {\normalfont\normalsize\bfseries}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\gdef\acknw{\section*{%
+{\acknwname}\markright{\protect\textsl{\acknwname}}}%
+\addcontentsline{toc}{section}{\acknwname}}
+\gdef\acknwname{Acknowledgment}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\renewcommand\sectionmark[1]{\markright{\thesection. #1}}
+\newcounter{lk}
+\newenvironment{listof}{\begin{list}{\rm(\roman{lk})}{\usecounter{lk}%
+\setlength{\topsep}{0ex plus0.1ex}%
+\setlength{\labelwidth}{1cm}%
+\setlength{\itemsep}{0ex plus0.1ex}%
+\setlength{\itemindent}{0.5cm}%
+}}{\end{list}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\title{Two applications of macros in \texttt{PSTricks}\thanks{PSTricks is the original work of Timothy Van Zandt (email address: \texttt{tvz@econ.insead.fr}).
+It is currently edited by Herbert Vo\ss\ (\texttt{hvoss@tug.org}).}\\
+{\Large\&} \\
+How to color arrows properly for a vector field}
+\author{Le Phuong Quan\\
+\small{(Cantho University, Vietnam)}\\
+\small{\texttt{lpquan@ctu.edu.vn}}}
+\begin{document}
+\maketitle
+\tableofcontents
+\section{Drawing approximations to the area under a graph by rectangles}
+\subsection{Description}
+
+We recall here an application in Calculus. Let $f(x)$ be a function, defined and bounded on
+the interval $[a,b]$. If $f$ is integrable (in Riemann sense) on $[a,b]$, then its definite integral over this interval
+is
+$$\int_a^bf(x)dx=\lim_{\|P\|\to 0}\sum_{i=1}^nf(\xi_i)\Delta x_i,$$
+where $P\colon a=x_0<x_1<\cdots<x_n=b$, $\Delta x_i=x_i-x_{i-1}$, $\xi_i\in[x_{i-1},x_i]$, $i=1,2,\ldots,n$,
+and $\|P\|=\max\{\Delta x_i\colon i=1,2,\ldots,n\}$. Hence, when $\|P\|$ is small enough, we may have an
+approximation
+\begin{equation}\label{eqn1}
+I=\int_a^bf(x)dx\approx\sum_{i=1}^nf(\xi_i)\Delta x_i.
+\end{equation}
+Because $I$ is independent to the choice of the partition $P$ and of the $\xi_i$, we may
+divide $[a,b]$ into $n$ subintervals with equal length and choose $\xi_i=(x_i+x_{i-1})/2$.
+Then, $I$ can be approximately seen as the sum of areas of the rectangles with sides
+$f(\xi_i)$ and $\Delta x_i$.
+
+We will make a drawing procedure to illustrate the approximation (\ref{eqn1}). Firstly, we establish
+commands to draw the \emph{sum\/} of rectangles, like the area under piecewise-constant functions
+(called \textsl{step shape\/}, for brevity). The choice here
+is a combination of the macros \texttt{\symbol{92}pscustom} (to \emph{join\/} horizontal segments, automatically)
+and \texttt{\symbol{92}multido}, of course. In particular, the horizontal segments are depicted within the loop
+\texttt{\symbol{92}multido} by
+$$\texttt{\symbol{92}psplot[{\it settings}]\{$x_{i-1}$\}\{$x_i$\}\{$f(\xi_i)$\}}$$
+The \texttt{\symbol{92}pscustom} will join these segments altogether with the end points
+$(a,0)$ and $(b,0)$, to make the boundary of the step shape. Then, we draw the points $(\xi_i,f(\xi_i))$, $i=1,2,\ldots,n$,
+and the dotted segments between these points and the points $(\xi_i,0)$, $i=1,2,\ldots,n$, by
+\begin{align*}
+&\texttt{\symbol{92}psdot[algebraic,\dots](*\{$\xi_i$\} \{$f(x)$\})},\\
+&\texttt{\symbol{92}psline[algebraic,linestyle=dotted,\dots]($\xi_i$,$0$)(*\{$\xi_i$\} \{$f(x)$\})},
+\end{align*}
+where we use the structure \texttt{(*\{{\it value}\} \{$f(x)$\})} to obtain the point $(\xi_i,f(\xi_i))$. Finally, we draw
+vertical segments to split the step shape into rectangular cells by
+$$\texttt{\symbol{92}psline[algebraic,\dots]($x_i$,$0$)(*\{$x_i$\} \{$f(x-\Delta x_i/2)$\})}$$
+The process of performing steps is depicted in Figure \ref{Fig1}.
+\begin{figure}[htbp]
+\centering\centering\begin{tabular}{cc}
+\includegraphics[height=5.5cm]{Fig1-1}
+&\includegraphics[height=5.5cm]{Fig1-2}
+\\
+\multicolumn{2}{c}{\includegraphics[height=5.5cm]{Fig1-3}}
+\end{tabular}
+\caption{Steps to make the drawing procedure.}\label{Fig1}
+\end{figure}
+
+We can combine the above steps to make a procedure whose calling sequence consists of main parameters
+$a$, $b$, $f$ and $n$, and dependent parameters $x_{i-1}$, $x_i$, $\xi_i$, $f(\xi_i)$ and
+$f(x\pm\Delta x_i/2)$. For instant, let us consider the approximations to the integral of $f(x)=\sin x-\cos x$
+over $[-2,3]$ in the cases of $n=5$ and $n=20$. Those approximations are given in Figure \ref{Fig2}.
+
+\begin{figure}[htbp]
+\centering\includegraphics[width=6cm]{Fig2-1}
+\hskip4em
+\includegraphics[width=6cm]{Fig2-2}
+\caption{Approximations to the integral of $f(x)=\sin x-\cos x$ over $[-2,3]$.}\label{Fig2}
+\end{figure}
+
+In fact, we can make a procedure to illustrate the approximation (\ref{eqn1}), say \texttt{RiemannSum}, whose calling sequence has the form
+$$\texttt{\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)$\}},$$
+where $x_0=a$ and for each $i=1,2\ldots,n$:
+\begin{align*}
+x_i&=a+\dfrac{b-a}{n}i,\quad\Delta x_i=x_i-x_{i-1}=\dfrac{b-a}{n},\\
+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.
+\end{align*}
+Note that $x_{\rm ini}$, $x_{\rm end}$ and $x_{\rm choice}$ are given in such forms to be
+suitable to variable declaration in \texttt{\symbol{92}multido}. They are nothing but
+$x_{i-1}$, $x_i$ and $\xi_i$, respectively, at the step $i$-th in the loop.
+
+Tentatively, in \texttt{PSTricks} language, the definition of \texttt{RiemannSum} is suggested to be
+\bigskip\hrule
+\noindent\begin{tabular}{@{}l}
+\verb!\def\RiemannSum#1#2#3#4#5#6#7#8#9{%!\\
+\verb!\psplot[linecolor=blue]{#1}{#2}{#3}!\\
+\verb!\pscustom[linecolor=red]{%!\\
+\verb!\psline{-}(#1,0)(#1,0)!\\
+\verb!\multido{\ni=#5,\ne=#6}{#4}!\\
+\verb!{\psline(*{\ni} {#8})(*{\ne} {#9})}}!\\
+\verb!\multido{\ne=#6,\nc=#7}{#4}!\\
+\verb!{\psdot(*{\nc} {#3})!\\
+\verb!\psline[linestyle=dotted,dotsep=1.5pt](\nc,0)(*{\nc} {#3})!\\
+\verb!\psline[linecolor=red](\ne,0)(*{\ne} {#9})}}!
+\end{tabular}\bigskip\hrule
+\subsection{Examples}
+We give here two more examples just to see that using the drawing procedure is very easy. In the first example, we approximate
+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
+the case $n=16$; thus $x_0=0$ and for each $i=1,\ldots,16$, we have
+$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$.
+\begin{figure}[htbp]
+\centering\includegraphics[width=5.1cm]{Fig3}
+\vskip0.5ex
+\caption{An approximation to the area under the graph of $f(x)=x-(x/2)\cos x+2$ on $[0,8]$.}\label{Fig3}
+\end{figure}
+
+To get Figure \ref{Fig3}, we have used the following \LaTeX\ code:
+\bigskip\hrule
+\noindent\begin{tabular}{@{}l}
+\verb!\begin{pspicture}(0,0)(4.125,5.5)!\\
+\verb!\psset{plotpoints=500,algebraic,dotsize=2.5pt,unit=0.5}!\\
+\verb!\RiemannSum{0}{8}{x-(x/2)*cos(x)+2}{16}{0.00+0.50}{0.50+0.50}{0.25+0.50}!\\
+\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}!\\
+\verb!\psaxes[ticksize=2.2pt,labelsep=4pt]{->}(0,0)(8.5,11)!\\
+\verb!\end{pspicture}!
+\end{tabular}
+\smallskip\hrule\bigskip
+
+In the second example below, we will draw an approximation to the integral of $f(x)=x\sin x$ over $[1,9]$.
+Choosing $n=10$ and computing parameters needed, we get Figure \ref{Fig4}, mainly by
+the command
+\begin{align*}
+&\texttt{\symbol{92}RiemannSum\{$1$\}\{$9$\}\{$x\sin x$\}\{$10$\}\{$1.00+0.80$\}\{$1.80+0.80$\}\{$1.40+0.80$\}}\\
+&\texttt{\{$(x+0.4)\sin(x+0.4)$\}\{$(x-0.4)\sin(x-0.4)$\}}
+\end{align*}
+in the drawing procedure.
+\begin{figure}[htbp]
+\centering\includegraphics[width=4.75cm]{Fig4}
+\caption{An approximation to the integral of $f(x)=x\sin x$ over $[1,9]$.}\label{Fig4}
+\end{figure}
+\section{Drawing the vector field of an ordinary differential equation of order one}
+\subsection{Description}\label{sect1}
+
+Let us consider the differential equation
+\begin{equation}\label{eqn2}
+\frac{dy}{dx}=f(x,y).
+\end{equation}
+At each point $(x_0,y_0)$ in the domain $D$ of $f$, we will put a vector $\mathbf{v}$ with slope
+$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)$
+of (\ref{eqn2}) at $(x_0,y_0)$. The $\mathbf{v}$'s make a \textsl{vector field\/} and the picture
+of this field would give us information about the shape of solution curves of (\ref{eqn2}), even
+we have not found yet any solution of (\ref{eqn2}).
+
+The vector field of (\ref{eqn2}) will be depicted on a finite grid of points in $D$. This grid is made of
+lines, paralell to the axes $Ox$ and $Oy$. The intersectional points of those lines are called \textsl{grid points\/}
+and often indexed by $(x_i,y_j)$, $i=0,\ldots,N_x$, $j=0,\ldots,N_y$. For convenience, we will use
+polar coordinate to locate the terminal point $(x,y)$ of a field vector, with the initial point at
+the grid point $(x_i,y_j)$. Then, we can write
+\begin{align*}
+x&=x_i+r\cos\varphi,\\
+y&=y_j+r\sin\varphi.
+\end{align*}
+Because $k=f(x_i,y_j)=\tan\varphi$ is finite, we may take $-\pi/2<\varphi<\pi/2$.
+From $\sin^2\varphi+\cos^2\varphi=1$ and $\sin\varphi=k\cos\varphi$, we derive
+$$\cos\varphi=\frac{1}{\sqrt{1+k^2}},\quad\sin\varphi=\frac{k}{\sqrt{1+k^2}}.$$
+\begin{figure}[htbp]
+\centering\includegraphics[width=5cm]{Fig5}
+\caption{Field vectors on a grid.}\label{Fig5}
+\end{figure}
+The field vectors should all have the same magnitude and we choose here that length to be
+$1/2$, that means $r=1/2$. Thus, vectors on the grid have their initial points and
+terminal ones as
+$$(x_i,y_j),\quad \Big(x_i+\frac{1}{2}\cos\varphi,y_j+\frac{1}{2}\sin\varphi\Big).$$
+
+Of macros in \texttt{PSTricks} to draw lines, we select \texttt{\symbol{92}parametricplot}\footnote{\footnotesize
+This macro is of ones, often added and updated in the package \texttt{pstricks-add}, the authors:
+Dominique Rodriguez (\texttt{dominique.rodriguez@waika9.com}), Herbert Vo\ss\ (\texttt{voss@pstricks.de}).}
+for its fitness. We immetiately have the simple parameterization of the vector at the grid point
+$(x_i,y_j)$ as
+\begin{align*}
+x&=x_i+\frac{t}{2}\cos\varphi=x_i+\frac{t}{2\sqrt{1+k^2}},\\
+y&=y_j+\frac{t}{2}\sin\varphi=y_j+\frac{tk}{2\sqrt{1+k^2}},
+\end{align*}
+where $t$ goes from $t=0$ to $t=1$, along the direction of the vector. The macro \texttt{\symbol{92}parametricplot}
+has the syntax as
+$$\texttt{\symbol{92}parametricplot[{\it settings}]\{$t_{\rm min}$\}\{$t_{\rm max}$\}\{$x(t)$|$y(t)$\}},$$
+where we should use the option \texttt{algebraic} to make the declaration of $x(t)$ and $y(t)$ simpler
+with \texttt{ASCII} code.
+
+From the above description of one field vector, we go to the one of the whole vector field
+on a grid belonging to the 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
+\begin{equation}\label{eqn3}
+a\le x_i\le b,\quad c\le y_j\le d.
+\end{equation}
+With respect to the indices $i$ and $j$, we choose initial values $x_0=a$ and
+$y_0=c$, with increments $\Delta x=\Delta y=\delta$, corresponding to the length of vectors and the distance
+between grid points as indicated in Figure \ref{Fig5}. Thus, to draw vectors at grid points
+$(x_i,y_j)$, we need two loops for $i$ and $j$, with $0\le i\le\lfloor m/\delta\rfloor$, $0\le j\le\lfloor n/\delta\rfloor$, where
+$m=b-a$, $n=d-c$. Apparently, these two loops are nested \texttt{\symbol{92}multido}s, with variable declaration
+for each loop as follows
+\begin{align*}
+\texttt{\symbol{92}nx}&=\text{initial value}+\text{increment}=x_0+\Delta x,\\
+\texttt{\symbol{92}ny}&=\text{initial value}+\text{increment}=y_0+\Delta y.
+\end{align*}
+Finally, we will replace \texttt{\symbol{92}nx}, \texttt{\symbol{92}ny} by $x_i$, $y_j$ in the
+below calling sequence for simplicity.
+
+Thus, the main procedure to draw the vector field of the equation (\ref{eqn2}) on the grid (\ref{eqn3})
+is
+\begin{align*}
+&\texttt{\symbol{92}multido\big\{$y_j=y_0+\Delta y$\big\}\big\{$\lfloor n/\delta\rfloor$\big\}}\texttt{\bigg\{\symbol{92}multido\big\{$x_i=x_0+\Delta x$\big\}\big\{$\lfloor m/\delta\rfloor$\big\}}\\
+&\quad\texttt{\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|
+$y_j+\frac{tf(x_i,y_j)}{2\sqrt{1+\big[f(x_i,y_j)\big]^2}}$\Big\}\bigg\}}
+\end{align*}
+where we at least use \texttt{arrows=->} and \texttt{algebraic} for \textit{settings}.
+
+We can combine the steps mentioned above to define a drawing procedure, say \texttt{\symbol{92}vecfld},
+that consists of main parameters in the order as
+\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$
+and $f(\texttt{\symbol{92}nx},\texttt{\symbol{92}ny})$. We may change these values to modify
+the vector field or to avoid the vector intersection. Such a definition is suggested to be
+\bigskip\hrule
+\noindent\begin{tabular}{@{}l}
+\verb!\def\vecfld#1#2#3#4#5#6{%!\\
+\verb!\multido{#2}{#4}{\multido{#1}{#3}!\\
+\verb!{\parametricplot[algebraic,arrows=->,linecolor=red]{0}{1}!\\
+\verb!{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}}}}!
+\end{tabular}\bigskip\hrule
+\subsection{Examples}
+Firstly, we consider the equation that describes an object falling in a resistive medium:
+\begin{equation}\label{eqn4}
+\frac{dv}{dt}=9.8-\frac{v}{5},
+\end{equation}
+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
+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
+$v=49$.
+\begin{figure}[htbp]
+\centering\includegraphics[width=8.55cm]{Fig6}
+\caption{The vector field of (\ref{eqn4}).}\label{Fig6}
+\end{figure}
+
+Figure \ref{Fig6} is made of the following \LaTeX\ code:
+\bigskip\hrule
+\noindent\begin{tabular}{@{}l}
+\verb!\begin{pspicture}(0,46)(9.5,52.5)!\\
+\verb!\vecfld{\nx=0.25+0.50}{\ny=46.25+0.50}{18}{12}{0.5}{9.8-0.2*\ny}!\\
+\verb!\psplot[algebraic,linewidth=1.2pt]{0}{9}{49}!\\
+\verb!\psaxes[Dy=1,Dx=1,Oy=46]{->}(0,46)(0,46)(9.5,52.5)!\\
+\verb!\rput(9.5,45.8){$t$}\rput(-0.2,52.5){$y$}!\\
+\verb!\end{pspicture}!
+\end{tabular}
+\smallskip\hrule\bigskip
+Let us next consider the problem
+\begin{equation}\label{eqn5}
+\frac{dy}{dx}=x+y,\quad y(0)=0.
+\end{equation}
+It is easy to check that $y=e^x-x-1$ is the unique solution to the problem (\ref{eqn5}). We now draw
+the vector field of (\ref{eqn5}) and the solution curve\footnote{\footnotesize
+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
+Figure \ref{Fig7}.
+\begin{figure}[htbp]
+\centering\includegraphics[width=3.25cm]{Fig7}
+\caption{The vector field of (\ref{eqn5}).}\label{Fig7}
+\end{figure}
+
+We then go to the logistic equation, which is chosen to be a model for the dependence
+of the population size $P$ on time $t$ in Biology:
+\begin{equation}\label{eqn6}
+\frac{dP}{dt}=kP\Big(1-\frac{P}{M}\Big),
+\end{equation}
+where $k$ and $M$ are constants, respectively various to selected species and environment.
+For specification, we take, for instant, $k=0.5$ and $M=100$. The right hand side of
+(\ref{eqn6}) then becomes $f(t,P)=0.5\,P(1-0.01\,P)$. In Figure \ref{Fig8}, we draw the vector field
+of (\ref{eqn6}) on the grid $R=\{(t,P)\colon 0\le t\le 10,\,95\le P\le 100\}$ and the equilibrium
+solution curve $P=100$. Furthermore, with the initial condition $P(0)=95$, the equation (\ref{eqn6})
+has the unique solution $P=1900(e^{-0.5t}+19)^{-1}$. This solution curve is also given in Figure \ref{Fig8}.
+\begin{figure}[htbp]
+\centering\includegraphics[width=8.4cm]{Fig8}
+\caption{The vector field of (\ref{eqn6}) with $k=0.5$ and $M=100$.}\label{Fig8}
+\end{figure}
+
+The previous differential equations are all of seperated variable or linear cases that
+can be solved for closed-form solutions by some simple integration formulas. We will consider one more
+equation of the non-linear case whose solution can only be approximated by numerical methods.
+The vector field of such an equation is so useful and we will use the Runge-Kutta curves (of order $4$)
+to add more information about the behaviour of solution curve. Here, those Runge-Kutta curves are depicted by the procedure
+\texttt{\symbol{92}psplotDiffEqn}, also updated from the package \texttt{pstricks-add}.
+
+The vector field of the non-linear differential equation
+\begin{equation}\label{eqn7}
+\frac{dy}{dx}=y^2-xy+1
+\end{equation}
+will be depicted on the grid $R=\{(x,y)\colon -3\le x\le 3,\,-3\le y\le 3\}$ and the solutions
+of Cauchy problems for (\ref{eqn7}), corresponding to initial conditions
+\begin{listof}
+\item $y(-3)=-1$,
+\item $y(-2)=-3$,
+\item $y(-3)=-0.4$,
+\end{listof}
+will be approximated by the method of Runge-Kutta, with the grid size $h=0.2$. It is very easy
+to recognize approximate curves, respective to (i), (ii) and (iii) in Figure \ref{Fig9} below.
+\begin{figure}[htbp]
+\centering\includegraphics[width=8.5cm]{Fig9}
+\caption{The vector field of (\ref{eqn7}) and the Runge-Kutta curves.}\label{Fig9}
+\end{figure}
+\section{Remarks on how to color arrows properly for a vector field}
+\subsection{Description}
+In the \verb!\vecfld! procedure, the command
+\begin{equation}\label{bosung1}
+\texttt{\symbol{92}parametricplot[{\it settings}]\{$t_{\rm min}$\}\{$t_{\rm max}$\}\{$x(t)$|$y(t)$\}}
+\end{equation}
+does the two works: drawing the whole oriented line segment and putting the endpoint right after
+the vector. This blots out the pointy head of arrows and makes field vectors less sharp when being seen closely.
+However, there is no problem with the procedure if we just want a monochrome vector field. But, in case of using arrows
+with their various color shades, we should use an independent procedure with options to draw a color arrow. For such a procedure,
+the command \texttt{\symbol{92}psline} could be the best choice. We just call it with two argument points, which are extracted from the curve
+produced by the command \texttt{\symbol{92}parametricplot}.
+
+To modify the \verb!\vecfld! procedure, from the above consideration, we might take the command \texttt{\symbol{92}curvepnodes} in the package \texttt{pst-node}\footnote{\footnotesize
+Package authors: Timothy Van Zandt (\texttt{tvz@econ.insead.fr}), Michael Sharpe (\texttt{msharpe@euclid.ucsd.edu}) and Herbert Vo\ss\ (\texttt{hvoss@tug.org}).} to
+extract points from a curve $(x(t),y(t))$ given in the algebraic form. Because we only need the two ending points of the curve,
+we can use
+\begin{equation}\label{bosung2}
+\texttt{\symbol{92}curvepnodes[algebraic,plotpoints=2]\{0\}\{1\}\{$x(t)$|$y(t)$\}\{P\}},
+\end{equation}
+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
+vector is drawn by the command
+\begin{equation}\label{bosung3}
+\texttt{\symbol{92}psline[linecolor={\it settings}]\{->\}(P0)(P1)}
+\end{equation}
+The command (\ref{bosung1}) may be replaced by the two ones (\ref{bosung2}) and (\ref{bosung3}), and we obtain the arrows whose heads are now sharper.
+
+The remaining problem is how to appropriately make \textit{settings} in (\ref{bosung3}) to bring out a vector field. Obviously, \textit{settings} should be
+various color shades according to slope of vectors. In Subsection \ref{sect1}, we know for the equation (\ref{eqn2}) that $f(x_i,y_j)$ is right the slope of
+field vectors at grid points $(x_i,y_j)$, and we will divide these slopes into some number of scales, corresponding to the
+degree of color shades. Here, we confine our interest to a continuous function $f(x,y)$ in two independent variables on the domain
+$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.
+
+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
+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$,
+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
+$n_{ij}=\lfloor 10|f(x_i,y_j)|/M\rfloor$, that is
+\begin{equation}\label{bosung4}n_{ij}M\le 10|f(x_i,y_j)|<(n_{ij}+1)M.\end{equation}
+For finding such an integer, in \TeX\ codes, we need one \texttt{\symbol{92}newcount} for it and two \texttt{\symbol{92}newdimen} for
+$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
+\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}
+(ref. to ``intermediate values''). Then, the integer $n_{ij}$ at stage $(i,j)$ within the two loops \texttt{\symbol{92}multido} can be defined by the recursive macro \texttt{\symbol{92}fintg} (ref. to ``find the integer'') as follows
+\begin{verbatim}
+ \def\fintg{\interm=Mpt \interm=\intg\interm%
+ \ifdim\ifdim\slope<0pt -\fi\slope>\interm \advance\intg by 1\fintg\fi}
+\end{verbatim}
+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
+by $10$ with the assignment \texttt{\symbol{92}slope=10\symbol{92}slope}, as defined in (\ref{bosung4}). Besides, by simulating the expression of $f(x,y)$, the calculation of $f(x_i,y_j)$
+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
+degree, say $k$, from $0$ to $10$ by its value, suitably associated to the command \texttt{\symbol{92}psline[linecolor=red!case-k]\{->\}(P0)(P1)}.
+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,
+making such a color scale is local and relative, so we can use one more parameter in the procedure to adjust color shades.
+The old procedure takes $6$ parameters and the new one will take two more parameters: one for a way of computing $f(x_i,y_j)$ and the other
+for adjusting color shades.
+
+Let us take some examples on how to compute $f(x_i,y_j)$ by \TeX\ codes or by the commands from the package \texttt{calculator}\footnote{\footnotesize
+Package author: Robert Fuster (\texttt{rfuster@mat.upv.es}).}. For a simple polynomial $f(x,y)$,
+computing $f(x_i,y_j)$ by \TeX\ codes might be facile. Because \verb!\nx! and \verb!\ny! are respectively holding the values of
+$x_i$ and $y_j$, we need the two corresponding dimensions \verb!\newdimen\fx! and \verb!\newdimen\fy! to take these values. By assigning \verb!\fx=\nx pt\fy=\ny pt!,
+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.
+
+\begin{table}[htbp]
+\centering\begin{tabular}{c|l}
+$f(x,y)$&\multicolumn{1}{c}{\TeX\ codes for computing $f(\texttt{\symbol{92}nx},\texttt{\symbol{92}ny})$} \\ \hline
+$x+y$&\verb!\advance\slope by \fx \advance\slope by \fy!\\ \hline
+$1-xy$&\verb!\advance\slope by -\decimal\fx\fy \advance\slope by 1pt!\\ \hline
+$y(3-y)$&\verb!\advance\slope by -\decimal\fy\fy \advance\slope by 3\fy!\\ \hline
+$y^2-xy$&\verb!\advance\slope by \decimal\fy\fy \advance\slope by -\decimal\fx\fy!\\ \hline
+\end{tabular}
+\end{table}
+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
+\begin{verbatim}
+ \def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
+ \xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
+\end{verbatim}
+
+For a transcendental or rational function $f(x,y)$, we should use the package \texttt{calculator} for
+computing $f(x_i,y_j)$. The following table shows how to perform the calculations.
+\begin{table}[htbp]
+\centering\begin{tabular}{c|l}
+$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
+$\sin(y-x)$&\verb!\SUBTRACT{\ny}{\nx}{\sola}\SIN{\sola}{\solb}\slope=\solb pt!\\ \hline
+\raisebox{-2ex}[0pt][0pt]{$2xy/(1+y^2)$}&\verb!\SUMfunction{\ONEfunction}{\SQUAREfunction}{\Fncty}!\\
+&\verb!\Fncty{\ny}{\soly}{\Dsoly}\DIVIDE{\Dsoly}{\soly}{\tempa}!\\
+&\verb!\MULTIPLY{\nx}{\tempa}{\tempb}\slope=\tempb pt!\\ \hline
+\end{tabular}
+\end{table}
+
+From the old macro \verb!\vecfld!, we will construct the new one \verb!\vecfldnew! by adding up to the former the two parameters as described above. According to
+the description of new parameters and of known ones, the calling sequence of \verb!\vecfldnew! may have the form of
+$$\texttt{\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$\}}$$
+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
+color shades. Finally, \verb!\intg! and \verb!\slope! should be reset to
+zero at the end of each stage. Now, all materials to make the new macro are ready, and a definition for it is suggested to be
+\bigskip\hrule
+\noindent\begin{tabular}{@{}l}
+\verb!\def\vecfldnew#1#2#3#4#5#6#7#8{%!\\
+\verb!\newcount\intg \newdimen\slope \newdimen\interm \newdimen\fx \newdimen\fy!\\
+\verb!\def\fintg{\interm=#8 \interm=\intg\interm%!\\
+\verb! \ifdim\ifdim\slope<0pt -\fi\slope>\interm \advance\intg by 1\fintg\fi}!\\
+\verb!\multido{#2}{#4}!\\
+\verb!{\multido{#1}{#3}!\\
+\verb!{\curvepnodes[algebraic,plotpoints=2]{0}{1}!\\
+\verb!{\nx+((#5)*t)*(1/sqrt(1+(#6)^2))|\ny+((#5)*t)*(1/sqrt(1+(#6)^2))*(#6)}{P}!\\
+\verb!#7\slope=10\slope \fintg \ifnum\intg>10\psline[linecolor=red]{->}(P0)(P1)!\\
+\verb+\else\ifnum\intg=0\psline[linecolor=red!5]{->}(P0)(P1)+\\
+\verb+\else\multiply\intg by 10\psline[linecolor=red!\the\intg]{->}(P0)(P1)\fi\fi+\\
+\verb+\intg=0\slope=0pt+\\
+\verb+}}}+
+\end{tabular}
+\smallskip\hrule\smallskip
+
+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
+$$\begin{array}{c}
+\verb!\ifcase\intg!\\
+\verb+\psline[linecolor=red!5]{->}(P0)(P1)\or+\\
+\verb+\psline[linecolor=red!10]{->}(P0)(P1)\or+\\
+\vdots\\
+\verb!\psline[linecolor=red]{->}(P0)(P1)\fi!
+\end{array}$$
+\subsection{Examples}
+The first example is given with the two $n_a$s to see how different the color shades are between the two cases. The left vector field in Figure \ref{figure1}
+is made of the calling sequence
+\begin{verbatim}
+\vecfldnew{\nx=-2.00+0.3}{\ny=-2.00+0.3}{14}{14}{0.3}{(\nx)-2*(\ny)}
+{\fy=\ny pt \fx=\nx pt \advance\slope by -2\fy \advance\slope by \fx}{9pt}
+\end{verbatim}
+\begin{figure}[htbp]
+\centering\includegraphics[width=4.6cm]{vec5}
+\hskip1cm\includegraphics[width=4.6cm]{vec6}
+\caption{The vector fields of the equation $y'=x-2y$ with $n_a=\texttt{9pt}$ (the left) and $n_a=\texttt{5pt}$ (the right)}\label{figure1}
+\end{figure}
+
+In Figure \ref{figure2}, the vector fields of the equations $y'=y-x$ and $y'=x(2-y)$ are respectively drawn by the calling sequences
+\begin{verbatim}
+\vecfldnew{\nx=-3.00+0.4}{\ny=-3.00+0.4}{15}{15}{0.35}{(\ny)-(\nx)}
+{\fy=\ny pt \fx=\nx pt \advance\slope by -\fx \advance\slope by \fy}{5pt}
+\end{verbatim}
+and
+\begin{verbatim}
+\vecfldnew{\nx=-3.00+0.4}{\ny=-3.00+0.4}{15}{15}{0.35}{(\nx)*(2-(\ny))}
+{\fy=\ny pt \fx=\nx pt \advance\slope by -\decimal\fx\fy
+\advance\slope by 2\fx}{6pt}
+\end{verbatim}
+\begin{figure}[htbp]
+\centering\includegraphics[width=6.2cm]{vec3}
+\hskip1cm\includegraphics[width=6.2cm]{vec4}
+\caption{The vector fields of the equation $y'=y-x$ (the left) and $y'=x(2-y)$ (the right).}\label{figure2}
+\end{figure}
+
+Finally, we consider two more examples on vector fields of differential equations $y'=f(x,y)$ containing trigonometric or rational functions on the right side. The calling sequences
+\begin{verbatim}
+\vecfldnew{\nx=-3.00+0.4}{\ny=-3.00+0.4}{15}{15}{0.35}{sin(\nx)*cos(\ny)}
+{\SIN{\nx}{\tmpa}\COS{\ny}{\tmpb}\MULTIPLY{\tmpa}{\tmpb}{\tmpc}
+\slope=\tmpc pt}{0.6pt}
+\end{verbatim}
+and
+\begin{verbatim}
+\vecfldnew{\nx=-3.00+0.3}{\ny=-3.00+0.3}{20}{20}{0.3}{2*(\nx)*(\ny)/(1+(\ny)^2)}
+{\SUMfunction{\ONEfunction}{\SQUAREfunction}{\Fncty}\Fncty{\ny}{\soly}{\Dsoly}
+\DIVIDE{\Dsoly}{\soly}{\tempa}\MULTIPLY{\nx}{\tempa}{\tempb}
+\slope=\tempb pt}{2.5pt}
+\end{verbatim}
+respectively result in the vector field on the left and on the right in Figure \ref{figure3}.
+
+\begin{figure}[htbp]
+\centering\includegraphics[width=6.2cm]{vec1}
+\hskip1cm\includegraphics[width=6.2cm]{vec2}
+\caption{The vector fields of the equation $y'=\sin(x)\cos(y)$ (the left) and $y'=2xy/(1+y^2)$ (the right).}\label{figure3}
+\end{figure}
+
+\acknw
+I am very grateful to
+\begin{itemize}
+\item Timothy Van Zandt, Herbert Vo\ss, Dominique Rodriguez and Michael Sharpe for helping me with
+their great works on \texttt{PSTricks}.
+\item H\`an Th\hantt\rlap\accentcircflx\ Th\`anh for helping me with his pdf\hskip.03em\LaTeX\ program.
+\item Robert Fuster for his very useful package \texttt{calculator}.
+\end{itemize}
+\begin{thebibliography}{10}
+\bibitem{one} Dominique Rodriguez, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pstricks-add}: Additional Macros for PSTricks\/}.
+Version 3.60, \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
+\bibitem{two} Timothy Van Zandt, Michael Sharpe \&\ Herbert Vo\ss. \textsl{\texttt{pst-node}: Nodes and node connections}.
+Version 1.29, \url{http://ctan.org/tex-archive/graphics/pstricks/contrib}, 2013
+\bibitem{three} Helmut Kopka \&\ Patrick W. Daly. \textsl{Guide to \LaTeX \/}.
+Addison-Wesley, Fourth Edition, 2004, ISBN 0321173856
+\bibitem{four} Timothy Van Zandt. \textsl{User's Guide\/}. Version 1.5,\\
+\url{http://ctan.org/tex-archive/graphics/pstricks/base}, 2007
+\bibitem{five}Eitan M. Gurari. \textsl{Writing With \TeX \/}, McGraw-Hill, Inc., 1994, ISBN 0-07-025207-6
+\bibitem{six} Robert Fuster. \textsl{\texttt{calculator-calculus}: Scientific Calculations With \LaTeX \/}. Version 1.0a,
+\url{http://ctan.org/tex-archive/macros/latex/contrib/calculator}, 2012
+\end{thebibliography}
+\end{document}