Mercurial > octave
annotate doc/interpreter/diffeq.txi @ 20901:afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
* scripts/ode/ode23.m: new file
* scripts/ode/private/runge_kutta_23.m: new file
* scripts/ode/module.mk: list new files
* doc/interpreter/diffeq.txi: mention ode23 among available solvers
* scripts/help/__unimplemented__.m: remove ode23 from list of unimplemented functions
author | Stefan Miereis <stefan.miereis@gmx.de> |
---|---|
date | Tue, 15 Dec 2015 13:59:17 +0100 |
parents | 75d09edcfc75 |
children | dba88797f69f |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
1 @c Copyright (C) 1996-2015 John W. Eaton |
7018 | 2 @c |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
9 @c |
7018 | 10 @c Octave is distributed in the hope that it will be useful, but WITHOUT |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
14 @c |
7018 | 15 @c You should have received a copy of the GNU General Public License |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
3294 | 18 |
4167 | 19 @node Differential Equations |
3294 | 20 @chapter Differential Equations |
21 | |
6700 | 22 Octave has built-in functions for solving ordinary differential equations, |
23 and differential-algebraic equations. | |
8828 | 24 All solvers are based on reliable ODE routines written in Fortran. |
3294 | 25 |
26 @menu | |
17152
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
16868
diff
changeset
|
27 * Ordinary Differential Equations:: |
f2a8592b8fbd
doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents:
16868
diff
changeset
|
28 * Differential-Algebraic Equations:: |
3294 | 29 @end menu |
30 | |
12578
f5a780d675a1
Clean up operator and function indices in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 @cindex differential equations |
3294 | 32 @cindex ODE |
33 @cindex DAE | |
34 | |
4167 | 35 @node Ordinary Differential Equations |
3294 | 36 @section Ordinary Differential Equations |
37 | |
38 The function @code{lsode} can be used to solve ODEs of the form | |
39 @tex | |
40 $$ | |
41 {dx\over dt} = f (x, t) | |
42 $$ | |
43 @end tex | |
10668
72585f1ca7a2
Replace @ifinfo with @ifnottex.
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
44 @ifnottex |
3294 | 45 |
46 @example | |
9067
8970b4b10e9f
Cleanup documentation for quad.texi and diffeq.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
47 @group |
3294 | 48 dx |
49 -- = f (x, t) | |
50 dt | |
9067
8970b4b10e9f
Cleanup documentation for quad.texi and diffeq.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
51 @end group |
3294 | 52 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
53 |
10668
72585f1ca7a2
Replace @ifinfo with @ifnottex.
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
54 @end ifnottex |
3294 | 55 |
56 @noindent | |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
57 using @nospell{Hindmarsh's} ODE solver @sc{lsode}. |
3294 | 58 |
6700 | 59 |
60 | |
3373 | 61 @DOCSTRING(lsode) |
3294 | 62 |
4115 | 63 @DOCSTRING(lsode_options) |
64 | |
3294 | 65 Here is an example of solving a set of three differential equations using |
66 @code{lsode}. Given the function | |
67 | |
68 @cindex oregonator | |
69 | |
70 @example | |
71 @group | |
16868
b028df1b1e81
doc: Mention oregonator.m in examples dir in documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
72 ## oregonator differential equation |
3294 | 73 function xdot = f (x, t) |
74 | |
75 xdot = zeros (3,1); | |
76 | |
77 xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) \ | |
78 - 8.375e-06*x(1)^2); | |
79 xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27; | |
80 xdot(3) = 0.161*(x(1) - x(3)); | |
81 | |
82 endfunction | |
83 @end group | |
84 @end example | |
85 | |
86 @noindent | |
87 and the initial condition @code{x0 = [ 4; 1.1; 4 ]}, the set of | |
88 equations can be integrated using the command | |
89 | |
90 @example | |
91 @group | |
92 t = linspace (0, 500, 1000); | |
93 | |
94 y = lsode ("f", x0, t); | |
95 @end group | |
96 @end example | |
97 | |
98 If you try this, you will see that the value of the result changes | |
99 dramatically between @var{t} = 0 and 5, and again around @var{t} = 305. | |
100 A more efficient set of output points might be | |
101 | |
102 @example | |
103 @group | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
104 t = [0, logspace(-1, log10(303), 150), \ |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
105 logspace(log10(304), log10(500), 150)]; |
3294 | 106 @end group |
107 @end example | |
108 | |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 See @nospell{Alan C. Hindmarsh}, |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 @cite{ODEPACK, A Systematized Collection of ODE Solvers}, |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
111 in Scientific Computing, @nospell{R. S. Stepleman}, editor, (1983) |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 for more information about the inner workings of @code{lsode}. |
3294 | 113 |
16868
b028df1b1e81
doc: Mention oregonator.m in examples dir in documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
114 An m-file for the differential equation used above is included with the |
b028df1b1e81
doc: Mention oregonator.m in examples dir in documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
115 Octave distribution in the examples directory under the name |
b028df1b1e81
doc: Mention oregonator.m in examples dir in documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
116 @file{oregonator.m}. |
b028df1b1e81
doc: Mention oregonator.m in examples dir in documentation.
Rik <rik@octave.org>
parents:
14856
diff
changeset
|
117 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
118 @menu |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
119 * Matlab-compatible solvers:: |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
120 @end menu |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
121 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
122 @node Matlab-compatible solvers |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
123 @subsection Matlab-compatible solvers |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
124 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
125 Octave also provides a set of solvers for initial value problems for Ordinary |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20533
diff
changeset
|
126 Differential Equations that have a @sc{matlab}-compatible interface. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
127 The options for this class of methods are set using the functions. |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20533
diff
changeset
|
128 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
129 @itemize |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
130 @item @code{odeset} |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20533
diff
changeset
|
131 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
132 @item @code{odeget} |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
133 @end itemize |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
134 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
135 Currently implemented solvers are: |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20533
diff
changeset
|
136 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
137 @itemize |
20719
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
138 @item @nospell{Runge-Kutta} methods |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20533
diff
changeset
|
139 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
140 @itemize |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
141 @item @code{ode45} Integrates a system of non--stiff ordinary differential equations |
20719
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
142 (non--stiff ODEs and DAEs) using second order @nospell{Dormand-Prince} |
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
143 method. This is a fourth--order accurate integrator therefore the local |
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
144 error normally expected is @math{O(h^5)}. This solver requires six |
d903cccb8de8
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
20716
diff
changeset
|
145 function evaluations per integration step. |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
146 @item @code{ode23} Integrates a system of non--stiff ordinary differential equations |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
147 (non-stiff ODEs and DAEs) using second order @nospell{Bogacki-Shampine} |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
148 method. This is a second-order accurate integrator therefore the local |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
149 error normally expected is @math{O(h^3)}. This solver requires three |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
150 function evaluations per integration step. |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
151 @end itemize |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
152 @end itemize |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
153 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
154 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
155 @DOCSTRING(ode45) |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
156 |
20901
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
157 @DOCSTRING(ode23) |
afe9c529760d
2015 Code Sprint: move ode23 and runge_kutta_23 from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20844
diff
changeset
|
158 |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
159 @DOCSTRING(odeset) |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
160 |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
161 @DOCSTRING(odeget) |
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
162 |
20844
75d09edcfc75
codesprint: Move odeplot.m from odepkg to core
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20719
diff
changeset
|
163 @DOCSTRING(odeplot) |
20533
fcb792acab9b
Moving ode45, odeset, odeget, and levenshtein from odepkg to core.
jcorno <jacopo.corno@gmail.com>
parents:
19697
diff
changeset
|
164 |
4167 | 165 @node Differential-Algebraic Equations |
3294 | 166 @section Differential-Algebraic Equations |
167 | |
4115 | 168 The function @code{daspk} can be used to solve DAEs of the form |
3294 | 169 @tex |
170 $$ | |
171 0 = f (\dot{x}, x, t), \qquad x(t=0) = x_0, \dot{x}(t=0) = \dot{x}_0 | |
172 $$ | |
173 @end tex | |
6700 | 174 @ifnottex |
3294 | 175 |
176 @example | |
177 0 = f (x-dot, x, t), x(t=0) = x_0, x-dot(t=0) = x-dot_0 | |
178 @end example | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
179 |
6700 | 180 @end ifnottex |
3294 | 181 |
182 @noindent | |
6700 | 183 where |
184 @tex | |
185 $\dot{x} = {dx \over dt}$ | |
186 @end tex | |
187 @ifnottex | |
188 @math{x-dot} | |
189 @end ifnottex | |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
190 is the derivative of @math{x}. The equation is solved using |
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
191 @nospell{Petzold's} DAE solver @sc{daspk}. |
4115 | 192 |
193 @DOCSTRING(daspk) | |
194 | |
195 @DOCSTRING(daspk_options) | |
3294 | 196 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
197 Octave also includes @sc{dassl}, an earlier version of @sc{daspk}, |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
198 and @sc{dasrt}, which can be used to solve DAEs with constraints |
4115 | 199 (stopping conditions). |
3294 | 200 |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
201 @DOCSTRING(dassl) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
202 |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
203 @DOCSTRING(dassl_options) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
204 |
4115 | 205 @DOCSTRING(dasrt) |
206 | |
207 @DOCSTRING(dasrt_options) | |
3294 | 208 |
19040
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
209 See @nospell{K. E. Brenan}, et al., @cite{Numerical Solution of Initial-Value |
3294 | 210 Problems in Differential-Algebraic Equations}, North-Holland (1989) for |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
211 more information about the implementation of @sc{dassl}. |