Mercurial > octave-nkf
annotate doc/interpreter/diffeq.txi @ 20606:1b62fc4e1b2f stable
doc: Cuddle parentheses in example code of for loop.
* stmt.txi: Cuddle parentheses in example code of for loop.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 07 Oct 2015 14:41:39 -0700 |
parents | 4197fc428c7d |
children | fcb792acab9b |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19630
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. | |
19627
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. | |
19627
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 | |
19074
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 | |
19074
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 |
4167 | 118 @node Differential-Algebraic Equations |
3294 | 119 @section Differential-Algebraic Equations |
120 | |
4115 | 121 The function @code{daspk} can be used to solve DAEs of the form |
3294 | 122 @tex |
123 $$ | |
124 0 = f (\dot{x}, x, t), \qquad x(t=0) = x_0, \dot{x}(t=0) = \dot{x}_0 | |
125 $$ | |
126 @end tex | |
6700 | 127 @ifnottex |
3294 | 128 |
129 @example | |
130 0 = f (x-dot, x, t), x(t=0) = x_0, x-dot(t=0) = x-dot_0 | |
131 @end example | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
132 |
6700 | 133 @end ifnottex |
3294 | 134 |
135 @noindent | |
6700 | 136 where |
137 @tex | |
138 $\dot{x} = {dx \over dt}$ | |
139 @end tex | |
140 @ifnottex | |
141 @math{x-dot} | |
142 @end ifnottex | |
19074
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 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
|
144 @nospell{Petzold's} DAE solver @sc{daspk}. |
4115 | 145 |
146 @DOCSTRING(daspk) | |
147 | |
148 @DOCSTRING(daspk_options) | |
3294 | 149 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
150 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
|
151 and @sc{dasrt}, which can be used to solve DAEs with constraints |
4115 | 152 (stopping conditions). |
3294 | 153 |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
154 @DOCSTRING(dassl) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
155 |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
156 @DOCSTRING(dassl_options) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
157 |
4115 | 158 @DOCSTRING(dasrt) |
159 | |
160 @DOCSTRING(dasrt_options) | |
3294 | 161 |
19074
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
162 See @nospell{K. E. Brenan}, et al., @cite{Numerical Solution of Initial-Value |
3294 | 163 Problems in Differential-Algebraic Equations}, North-Holland (1989) for |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
164 more information about the implementation of @sc{dassl}. |