Debian Codegraph @

texmf-dist/doc/generic/pst-ode/pst-ode-doc.tex

raw
1 \documentclass[
2 fontsize=11pt,
3 english,
4 BCOR=10mm,DIV=12,
5 bibliography=totoc,
6 parskip=false,
7 headings=small,
8 headinclude=false,
9 footinclude=false,
10 twoside=false,
11 % dvips,
12 UKenglish
13 ]{pst-doc-new}
14 \usepackage[T1]{fontenc}
15 %\usepackage{lmodern}
16 \usepackage[tt=false]{libertine} %override beramono (doesn't look like tt font)
17 \usepackage{libertinust1math}
18 %\usepackage[scaled=0.83]{luximono} %override beramono (doesn't look like tt font)
19 \usepackage{attachfile2}
20 \attachfilesetup{date={},color=1 0 0}
21 %\usepackage[utf8]{inputenc}
22 \usepackage{amsmath}
23 \usepackage{pst-3dplot}
24 \usepackage{pst-plot}
25 \usepackage{pstricks-add}
26 \usepackage{pst-ode}
27 \usepackage[ocgcolorlinks]{ocgx2}
28 \let\pstFV\fileversion
29 \let\belowcaptionskip\abovecaptionskip
30
31 \def\bgImage{%
32 \pstVerb{
33 /alpha 10 def
34 /beta 28 def
35 /gamma 8 3 div def
36 }%
37 \pstODEsolve[algebraic,dt0=0.05]{lorenzXYZ}{0 1 2}{0}{25}{2501}{10 10 30}{
38 alpha*(x[1]-x[0]) |
39 x[0]*(beta-x[2]) - x[1] |
40 x[0]*x[1] - gamma*x[2]
41 }
42 \begin{pspicture}(-8,-4)(6,12)
43 \psset{unit=0.17cm,Alpha=160,Beta=15}
44 \listplotThreeD{lorenzXYZ}
45 \psset{unit=0.425cm,linestyle=dashed}
46 \pstThreeDNode(0,0,0){O}
47 \pstThreeDNode(0,0,5){Z}
48 \pstThreeDNode(5,0,0){X}
49 \pstThreeDNode(0,5,0){Y}
50 \pstThreeDNode(-10,-10,0){A}
51 \pstThreeDNode(-10,-10,20){B}
52 \pstThreeDNode(-10,10,20){C}
53 \pstThreeDNode(-10,10,0){D}
54 \pstThreeDNode(10,-10,0){E}
55 \pstThreeDNode(10,-10,20){F}
56 \pstThreeDNode(10,10,20){G}
57 \pstThreeDNode(10,10,0){H}
58 \pspolygon(A)(B)(C)(D)
59 \pspolygon(E)(F)(G)(H)
60 \psline(A)(E)
61 \psline(B)(F)
62 \psline(D)(H)
63 \psline(C)(G)
64 \psset{linestyle=solid,linecolor=red}
65 \psline{->}(O)(X)
66 \psline{->}(O)(Y)
67 \psline{->}(O)(Z)
68 \end{pspicture}
69 }
70 \lstset{explpreset={pos=l,width=-99pt,overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,rframe={}},
71 escapechar=?}
72 \def\textat{\char064}%
73 \let\verbI\texttt
74
75
76 \def\parsedate#1/#2/#3\relax{
77 \def\year{#1}
78 \def\month{#2}
79 \def\day{#3}
80 }
81
82 \author{Alexander Grahn}
83 \expandafter\parsedate\filedate\relax %set current date to package date
84 \title{pst-ode\\[4ex]}
85 \subtitle{A PSTricks package for solving initial value problems for sets of Ordinary Differential Equations (ODE), v\pstFV\\[2ex]\url{https://gitlab.com/agrahn/pst-ode}}
86
87 \begin{document}
88 \settitle
89
90 %\clearpage
91 \begin{abstract}
92 \noindent The \LPack{pstricks-add} package already provides \Lcs{psplotDiffEqn} for solving ODEs. However, as its name suggests, the macro always produces a plot of the computed result. While any number of coupled differential equations can be integrated simultaneously, only two-dimensional plots are supported. The user has to select the two components of the computed state vectors to be used in the plot.
93
94 Package \LPack{pst-ode} separates solving the equations from plotting the result. The result is stored as a \PS{} object and can be plotted later using macros from other PSTricks packages, such as \Lcs{listplot} (\LPack{pst-plot}) and \Lcs{listplotThreeD} (\LPack{pst-3dplot}), or be further processed by user-defined \PS{} procedures. Optionally, the computed state vectors can be written as a table to a text file.
95
96 Package \LPack{pst-ode} uses the Runge-Kutta-Fehlberg (RKF45) method with automatic step size control for integrating the differential equations. Thus, the precision of the result does not depend on the number of plot points specified, as it would be the case with the classical Runge-Kutta (RK4) method.
97 \end{abstract}
98
99 \tableofcontents
100
101 \section{Introduction}
102 An initial value problem involves finding the solution $\mathbf{x}(t)$ of a set of first order differential equations
103 \begin{equation}
104 \frac{\mathrm{d}\mathbf{x}}{\mathrm{d}t}=\mathbf{f}(t,\mathbf{x})
105 \end{equation}
106 by integrating them with respect to the independent variable $t$. If the set consists of $n$ differential equations,
107 a vector of initial conditions
108 \begin{equation}
109 \mathbf{x}(t_0)=\mathbf{x}_0
110 \end{equation}
111 of the same length $n$ is required. For $n=1$ the initial value problem is one-dimensional:
112 \begin{gather}
113 % \frac{\mathrm{d}x}{\mathrm{d}t}=f(t,x)\quad\text{for}\ t \in [t_0, t_\mathrm{e}]\text{, where}\label{eq:1dode}\\
114 \frac{\mathrm{d}x}{\mathrm{d}t}=f(t,x),\label{eq:1dode}\\
115 x(t_0) = x_0.\label{eq:1ini}
116 \end{gather}
117
118 Instead of producing analytical expressions of the solution functions $\mathbf{x}(t)$, the numerical method gives only approximate values $\mathbf{x}_i$ at $N$ discrete points $t_i$ in the interval $I=[t_0, t_\mathrm{e}]$ of the independent variable $t$:
119 \begin{equation}
120 \mathbf{x}_i\approx\mathbf{x}(t_i).
121 \end{equation}
122 The computed approximations $\mathbf{x}_i$ of the solution as well as the initial condition vector $\mathbf{x}_0$ are called `state vectors'. In the case of a single equation problem, Eqs.~\eqref{eq:1dode}, \eqref{eq:1ini}, state vectors have only one component.
123
124 \section{Commands}
125 \begin{BDef}
126 \Lcs{pstODEsolve}\OptArgs\Largb{result}\Largb{output format}\Largb{$t_0$}\Largb{$t_\mathrm{e}$}\Largb{$N$}\Largb{$\mathbf{x}_0$}\Largb{$\mathbf{f}(t,\mathbf{x})$}
127 \end{BDef}
128 is the main user command for solving initial value problems.
129
130 The first mandatory argument \Larg{result} is a simple identifier composed of letters and possibly numbers. It is the name of a \PS{} object that takes the computed state vectors $\mathbf{x}_i$, formatted according to the second argument \Larg{output format}, as a long list of values. \Larg{result} can be directly used as the \Larg{data} argument of \Lcs{listplot}\Largb{data} (package \LPack{pst-plot}) or \Lcs{listplotThreeD}\Largb{data} (package \LPack{pst-3dplot}). When put on the \PS{} operand stack, \Larg{result} is immediately executed, that is, the list of values contained in \Larg{result} is pushed onto the operand stack. The scope of \Larg{result} is global and thus its content survives page breaks.
131
132 The second argument \Larg{output format} determines which of the components of the state vectors $\mathbf{x}_i$ and possibly the independent variable $t$ are stored into \Larg{result}. \Larg{output format} can be specified in two different formats, depending on the setting of the command option \Lkeyword{algebraicOutputFormat}.
133 If \Lkeyword{algebraicOutputFormat} is set, calculations can be made on the components of the computed state vectors before writing them to \Larg{result}. Without option \Lkeyword{algebraicOutputFormat} the following applies: The keyword \Lkeyword{(t)} (parentheses required) inserts the integration parameter value $t_i$ into the result list; numbers (\Lkeyword{0}, \Lkeyword{1}, \Lkeyword{2}, \dots, $n-1$) in arbitrary order specify the components of vector $\mathbf{x}_i$ to be inserted, as well as their order of insertion. The elements of \Larg{output format} are to be separated by spaces. If option \Lkeyword{algebraicOutputFormat} is set, \Larg{output format} is a \Lkeyword{|}-separated list of algebraic expressions (infix notation) according to which the components of the output vector are to be calculated. In these algebraic expressions, the $n$ current state vector components can be referred to as \Lkeyword{x[0]}, \Lkeyword{x[1]}, \dots, \Lkeyword{x[}$n-1$\Lkeyword{]} or \Lkeyword{y[0]}, \Lkeyword{y[1]}, \dots, \Lkeyword{y[}$n-1$\Lkeyword{]}, and the current independent variable value as `\Lkeyword{t}'. In either case, there is no upper limit of the output vector length. It must have at least one element though.
134
135 Arguments $t_0$ and $t_\mathrm{e}$ define the interval of integration $I=[t_0, t_\mathrm{e}]$. Both arguments accept expressions in infix or \PS{} (postfix, reverse polish) notation. Infix notation requires option \Lkeyword{algebraicT}.
136
137 $N$ is the number of \emph{equally} spaced output points, including $t_0$ and $t_\mathrm{e}$; it must be $\ge 2$. In order to divide the interval of integration into $K$ output steps, $N$ must be set to $K+1$. Note that the precision of the solution does \emph{not} depend on $N$; internal integration steps are automatically inserted and resized according to the changes in the solution. This argument accepts an expression in postfix and, if \Lkeyword{algebraicN} is set, in infix notation.
138
139 $\mathbf{x}_0$ is a list of $n$ space separated initial values, one for each differential equation. Alternatively, $\mathbf{x}_0$ can be given as a \PS{} procedure pushing the initial values on the stack, or as an algebraic expression in infix notation where the elements are separated by `\Lkeyword{|}'. Infix notation requires option \Lkeyword{algebraicIC}. This argument can be left empty. In that case, the last computed state vector of a preceding \Lcs{pstODEsolve} call serves as initial condition. Of course, the number of equations $n$ must be the same as in the preceding calculation.
140
141 $\mathbf{f}(t,\mathbf{x})$ is the right-hand side of the differential equations. Equations can be entered in either infix or \PS{} (postfix, reverse polish) notation. Infix notation requires option \Lkeyword{algebraic}, and equations have to be separated by `\Lkeyword{|}'. The $n$ current state vector components can be referred to as \Lkeyword{x[0]}, \Lkeyword{x[1]}, \dots, \Lkeyword{x[}$n-1$\Lkeyword{]} or \Lkeyword{y[0]}, \Lkeyword{y[1]}, \dots, \Lkeyword{y[}$n-1$\Lkeyword{]}, and the current independent variable value as `\Lkeyword{t}'. If given in \PS{} notation, the provided procedure must first pop the current state vector components in reverse order(!) from the operand stack and then push the first derivatives in regular order back to it. Again, the independent variable value can be accessed using `\Lkeyword{t}'.%\\
142
143 \newpage
144 \noindent\Lcs{pstODEsolve} accepts a few \OptArgs:\\% \Lkeyword{dt0}, \Lkeyword{append}, \Lkeyword{saveData}, \Lkeyword{algebraicOutputFormat}, \Lkeyword{algebraicT}, \Lkeyword{algebraicN}, \Lkeyword{algebraicIC}, \Lkeyword{algebraic}, \Lkeyword{algebraicAll}, \Lkeyword{silent}, \Lkeyword{varsteptol} and \Lkeyword{rk4}.\\
145
146 \noindent\OptArg*{dt0=<number>}\\
147 \noindent By default, the output step $(t_\mathrm{e}-t_\mathrm{0})/(N-1)$ is used as the intitial, tentative integration step size. A large initial step may cause the integration to crash early by numerical overflow, in particular if the right-hand side evaluates to large values. With option \Lkeyword{dt0}, an arbitrary value of the initial step size can be specified.\\
148
149 \noindent\OptArg*{append}\\
150 If the initial condition argument $\mathbf{x}_0$ of \Lcs{pstODEsolve} is left empty, integration of an ODE continues from an already existing state, which was obtained by the most recent use of \Lcs{pstODEsolve} or which was re-instated from a previously saved state (\Lcs{pstODEsaveState}) by calling \Lcs{pstODErestoreState}. Keyword \Lkeyword{append} tells \Lcs{pstODEsolve} to append the computed result to \Larg{result} which must already exist.\\
151
152 \noindent\OptArg*{saveData}\\
153 If option \Lkeyword{saveData} is set, the formatted state vectors are written as a table to a textfile named `\Larg{result}\Lkeyword{.dat}'. Note that \Lkeyword{ps2pdf} must be called with option \Lkeyword{-dNOSAFER} to enable writing of external files.\\
154
155 \noindent\OptArg*{algebraicOutputFormat}\\
156 With \Lkeyword{algebraicOutputFormat}, the command argument \Larg{output format} is a \Lkeyword{|}-separated list of algebraic expressions in infix notation, according to which the output vector components are to be assembled before storing them into \Larg{result}. Default is to \emph{not} use algebraic infix expressions. For details, see the description of \Larg{output format} above.\\
157
158 \noindent\OptArg*{algebraicT}\\
159 With \Lkeyword{algebraicT}, the integration interval limits $t_0$ and $t_\mathrm{e}$ can be entered as algebraic expressions in infix notation, otherwise \PS{} (postfix, reverse polish) notation must be used. Of course, single rational numbers for $t_0$ and $t_\mathrm{e}$ always work.\\
160
161 \noindent\OptArg*{algebraicN}\\
162 In addition to a literal integer number or a \PS{} expression, option \Lkeyword{algebraicN} allows the number of output points $N$ to be provided as an infix expression.\\
163
164 \noindent\OptArg*{algebraicIC}\\
165 With \Lkeyword{algebraicIC}, the initial condition vector $\mathbf{x}_0$ can be given in algebraic infix notation. Vector components have to be separated by `\Lkeyword{|}'. Default is \PS{} notation, i.\,e. space separated postfix expressions or rational numbers.\\
166
167 \noindent\OptArg*{algebraic}\\
168 With \Lkeyword{algebraic}, the right-hand side of differential equations $\mathbf{f}(t,\mathbf{x})$ can be given in infix notation. Algebraic infix expressions are to be separated by `\Lkeyword{|}'. Default is \PS{} notation.\\
169
170 \noindent\OptArg*{algebraicAll}\\
171 Option \Lkeyword{algebraicAll} is equivalent to setting all of \Lkeyword{algebraicOutputFormat}, \Lkeyword{algebraicT}, \Lkeyword{algebraicN}, \Lkeyword{algebraicIC}, \Lkeyword{algebraic}.\\
172
173 \noindent\OptArg*{silent}\\
174 Option \Lkeyword{silent} suppresses the terminal output of stepping information.\\
175
176 \noindent\OptArg*{varsteptol=<number>}\\
177 The tolerance for automatic calculation of the integration step size can be set with \Lkeyword{varsteptol}. The default value is \Lkeyword{1e-6}. Sometimes, it may be helpful to relax this value in order to cope with situations where integration stops with step size underflow. The occurence of step size underflow is indicated by writing `\Lkeyword{!}' to the terminal and integration stops prematurely before reaching $t_\mathrm{e}$. The current value of $t$ and the current state vector $\mathbf{x}$ are written to the terminal. Step size underflow may happen for stiff ODEs at some point along the integration interval $[t_0, t_\mathrm{e}]$.\\
178
179 \noindent\OptArg*{rk4}\\
180 With this option, the classical 4th-order Runge-Kutta method is used to integrate the ODE between output points. No automatic step size control is performed in this case. This option is provided mainly for comparison purposes.\\[1ex]
181
182 \begin{BDef}
183 \Lcs{pstODEsaveState}\Largb{state}
184 \end{BDef}
185 is a user command to save the state of an integration at the end of a \Lcs{pstODEsolve} call. The saved state can be restored later, using \Lcs{pstODErestoreState}\Largb{state}, in order to continue the integration of an ODE. \Larg{state} is an identifier composed of letters and possibly numbers.\\[1ex]
186
187 \begin{BDef}
188 \Lcs{pstODErestoreState}\Largb{state}
189 \end{BDef}
190 is a user command to restore a previously saved state (\Lcs{pstODEsaveState}\Largb{state}). After restoring a state, \Lcs{pstODEsolve} can be called with an empty initial condition argument in order to continue integration of the ODE. Of course, the number of differential equations of the current and of the saved \Lcs{pstODEsolve} calls must be the same.
191
192 \section{Examples}
193 Complete and compilable example files are located in the \Verb+{TEXMFDIST}/doc/generic/pst-ode/examples+ directory.
194
195 \subsection[Lorenz Attractor]{Lorenz Attractor \textattachfile{examples/lorenz.tex}{($\nearrow$lorenz.tex)}}
196 The Lorenz Attractor depicted on the title page is governed by
197 \begin{align*}
198 \frac{\mathrm{d}x}{\mathrm{d}t}& = \alpha (y-x)\\
199 \frac{\mathrm{d}y}{\mathrm{d}t}& = x(\beta-z)-y\\
200 \frac{\mathrm{d}z}{\mathrm{d}t}& = x y - \gamma z.
201 \end{align*}
202 This system of differential equations is known to display chaotic behaviour due to the non-linear combination (products) of the dependent functions $x(t)$, $y(t)$ and $z(t)$. The trajectory of solution is susceptible to slight changes in the initial conditions and hence to slight discrepancies in the computed intermediate state vectors, which in turn can be regarded as initial conditions for the continuation of the solution. This is known as the `butterfly effect', a term coined by Lorenz. Although an adaptive stepping algorithm is used, the solution of this initial problem \emph{does} therefore depend on the number of output points chosen. To some extent, this fact contrasts with the statement made in the abstract of this documentation. However, for linear problems which only know one distinct solution it still holds. In the present case, the values $\alpha=10$, $\beta=28$, $\gamma=8/3$ and the initial condition $\mathbf{x}_0=(10,10,30)$ where chosen. The integration parameter $t$ is running from $0$ to $25$ and the state vector is output at $2501$ points of the integration interval.
203
204 \begin{verbatim}
205 \pstVerb{
206 /alpha 10 def
207 /beta 28 def
208 /gamma 8 3 div def
209 }
210 \pstODEsolve[algebraic]{lorenzXYZ}{0 1 2}{0}{25}{2501}{10 10 30}{
211 alpha*(x[1]-x[0]) |
212 x[0]*(beta-x[2]) - x[1] |
213 x[0]*x[1] - gamma*x[2]
214 }
215 \listplotThreeD{lorenzXYZ}
216 \end{verbatim}
217 As the plot is three-dimensional, all three components of the state vectors are stored in the \PS{} variable \Lkeyword{lorenzXYZ} by setting the \Larg{output format} argument to `\Lkeyword{0 1 2}'.
218
219 \subsection[Charged particle movement in a vertical electrical field]{Charged particle movement in a vertical electrical field \textattachfile{examples/particle.tex}{($\nearrow$particle.tex)}}
220 The trajectory $\mathbf{x}(t)$ of the particle shown below is governed by a set of three second order differential equations:
221 \begin{subequations}
222 \begin{align}
223 \ddot{x} &= \omega\dot{y}-\dfrac{\dot{x}}{\tau}\\
224 \ddot{y} &= -\omega\dot{x}-\dfrac{\dot{y}}{\tau}\\
225 \ddot{z} &= -\dfrac{\dot{z}}{\tau},
226 \end{align}
227 \end{subequations}
228 where $\omega$ and $\tau$ are constants. An initial value problem of this type needs $3\times2=6$ initial conditions. These are given as the initial position $\mathbf{x}_0=(x_0, y_0, z_0)$ and the initial velocity $\dot{\mathbf{x}}_0=(\dot{x}_0, \dot{y}_0, \dot{z}_0)=(u_0, v_0, w_0) = \mathbf{v}_0$ of the particle.
229
230 In order to solve the equations above numerically, they have to be rewritten as a set of six first order differential equations:
231 \begin{subequations}
232 \begin{align}
233 \dot{x} &= u\\
234 \dot{y} &= v\\
235 \dot{z} &= w\\
236 \dot{u} &= \omega v-\frac{u}{\tau}\\
237 \dot{v} &= -\omega u-\dfrac{v}{\tau}\\
238 \dot{w} &= -\dfrac{w}{\tau}.
239 \end{align}
240 \end{subequations}
241
242 Here, $\omega$ and $\tau$ are both set to the value of $5$, the initial position of the particle is defined as $\mathbf{x}_0=(0, 0, 0)$ and its initial velocity vector as $\mathbf{v}_0=(20, 0, 2)$. The integration parameter $t$ is running from $0$ to $25$ and the state vector is output at $1000$ points of the integration interval.
243 \begin{verbatim}
244 \pstVerb{
245 /wc 5 def
246 /tau 5 def
247 }
248 \pstODEsolve[algebraic]{particleXYZ}{0 1 2}{0}{25}{1000}{0 0 0 20 0 2}{
249 x[3] | x[4] | x[5] | wc*x[4] - x[3]/tau | -wc*x[3] - x[4]/tau | -x[5]/tau
250 }
251 \listplotThreeD{particleXYZ}
252 \end{verbatim}
253 Since we are interested in plotting the particle positions, only the first three components of the state vectors are stored in \Lkeyword{particleXYZ}.
254 \begin{center}
255 \psset{unit=0.75cm,Alpha=40,Beta=20}
256 \begin{pspicture}(-10,-2)(6,13)
257 \newpsstyle{vecteurA}{arrowinset=0.1,arrowsize=0.15,linecolor={[rgb]{0 0.5 1}}}
258 \pstVerb{
259 /wc 5 def
260 /tau 5 def
261 /vx 20 def
262 /vz 2 def
263 }
264 \pstODEsolve[algebraic]{particleXYZ}{0 1 2}{0}{25}{1000}{0 0 0 vx 0 vz}{
265 y[3] | y[4] | y[5] | wc*y[4] - y[3]/tau | -wc*y[3] - y[4]/tau | -y[5]/tau
266 }
267 \listplotThreeD{particleXYZ}
268 \pstThreeDNode(0,0,0){O}
269 \pstThreeDNode(0,0,1){Z}
270 \pstThreeDNode(1,0,0){X}
271 \pstThreeDNode(0,1,0){Y}
272 \pstThreeDNode(-5,-9,0){A}
273 \pstThreeDNode(-5,-9,10){B}
274 \pstThreeDNode(-5,2,10){C}
275 \pstThreeDNode(-5,2,0){D}
276 \pstThreeDNode(5,-9,0){E}
277 \pstThreeDNode(5,-9,10){F}
278 \pstThreeDNode(5,2,10){G}
279 \pstThreeDNode(5,2,0){H}
280 \pstThreeDNode(0,0,0){M0}
281 \pstThreeDNode(vx 5 div,0,vz 5 div){V}
282 \pstThreeDNode(vx 5 div,0,0){Vx}
283 {\psset{linestyle=dashed}
284 \pspolygon(A)(B)(C)(D)
285 \pspolygon(E)(F)(G)(H)
286 \psline(A)(E)
287 \psline(B)(F)
288 \psline(D)(H)
289 \psline(C)(G)}%
290 \psline[linecolor=red]{->}(M0)(V)
291 \psline[linecolor=cyan]{->}(M0)(Vx)
292 \uput{0.1}[l](V){\red$\overrightarrow{v}_0$}
293 {\psset{linestyle=solid,linecolor=red}
294 \psline[style=vecteurA]{->}(O)(X)
295 \psline[style=vecteurA]{->}(O)(Y)
296 \psline[style=vecteurA]{->}(O)(Z)}%
297 \uput[u](Z){$z$}
298 \uput[dl](X){$x$}
299 \uput[r](Y){$y$}
300 \end{pspicture}
301 \end{center}
302
303 \subsection[One more first order differential equation]{One more first order differential equation \textattachfile{examples/ode.tex}{($\nearrow$ode.tex)}}
304 The aim of the last example is to demonstrate that precision does not depend on the number of output points. We set only five output points and plot the analytical solution against the numerical one for comparison.
305
306 The ODE to be solved reads
307 \begin{equation}
308 y'=-2y t.\label{eq:ode}
309 \end{equation}
310 It should be noted that the right-hand side also depends the integration parameter $t$. % as well as in the output format description, since the solution $y$ shall be plotted against $t$.
311 With the initial condition
312 \begin{equation}
313 y(-1)=1/e\label{eq:initcond}
314 \end{equation}
315 the analytical solution of Eq.~\eqref{eq:ode} is
316 \begin{equation}
317 y(t)=e^{-t^2}.
318 \end{equation}
319 \begin{verbatim}
320 \pstODEsolve[algebraicIC,algebraic]{TY}{(t) 0}{-1}{3}{5}{1/Euler}{-2*t*y[0]}
321 \listplot[plotstyle=dots]{TY}
322 \end{verbatim}
323 Note that in \Lcs{pstODEsolve}, `\Lkeyword{x[..]}' and `\Lkeyword{y[..]}' can be used interchangeably for representing the state vector in algebraic notation. The initial condition~\eqref{eq:initcond} is given as an algebraic expression, which requires option \Lkeyword{algebraicIC}; in \PS{} notation it would read `\Lkeyword{1 Euler div}'. The integration parameter and the one available state vector component are stored into the \PS{} object `\Lkeyword{TY}' by setting \Larg{output format} to `\Lkeyword{(t) 0}'.
324 \begin{center}
325 \psset{unit=3cm}
326 \begin{pspicture}(-0.3,-0.4)(.2,1)%\psgrid
327 \psset{xAxisLabel=$t$,xAxisLabelPos={c,-6ex},yAxisLabelPos={-3ex,c}}
328 \begin{psgraph}[axesstyle=frame,Ox=-1,](0,0)(0,0)(4,1){10cm}{2.5cm}
329 \rput(1,0){\psplot[algebraic]{-1}{3}{Euler^(-x^2)}}
330 \pstODEsolve[algebraicIC,algebraic]{TY}{(t) 0}{-1}{3}{5}{1/Euler}{-2*t*y[0]}
331 \rput(1,0){\listplot[plotstyle=dots,dotsize=0.05,linecolor=red]{TY}}
332 \end{psgraph}
333 \end{pspicture}
334 \end{center}
335 The plot contains the analytical solution and the five output points of the numerical solution as red dots. They lie exactly on the analytic solution.
336
337 \section{Acknowledgements}
338 I'd like to thank Manuel Luque for the inspiring examples on his site \url{http://pstricks.blogspot.fr}, some of which I used as a basis for this documentation.
339
340 \section{License}
341 This package can be redistributed and/or modified under the terms
342 of the \LaTeX\ Project Public License\\
343 \url{http://www.latex-project.org/lppl.txt}
344
345 \end{document}